Class: OsCtld::Assets::Validator
- Inherits:
-
Object
- Object
- OsCtld::Assets::Validator
- Defined in:
- lib/osctld/assets/validator.rb
Defined Under Namespace
Classes: Run
Instance Attribute Summary collapse
- #assets ⇒ Array<Asset::Base> readonly
Instance Method Summary collapse
- #add_asset(asset) ⇒ Object
- #add_assets(new_assets) ⇒ Object
-
#initialize(assets = []) ⇒ Validator
constructor
A new instance of Validator.
-
#validate ⇒ Array<Asset::Base>
Validate and return assets.
Constructor Details
#initialize(assets = []) ⇒ Validator
Returns a new instance of Validator.
11 12 13 |
# File 'lib/osctld/assets/validator.rb', line 11 def initialize(assets = []) @assets = assets.clone end |
Instance Attribute Details
#assets ⇒ Array<Asset::Base> (readonly)
8 9 10 |
# File 'lib/osctld/assets/validator.rb', line 8 def assets @assets end |
Instance Method Details
#add_asset(asset) ⇒ Object
16 17 18 |
# File 'lib/osctld/assets/validator.rb', line 16 def add_asset(asset) assets << asset end |
#add_assets(new_assets) ⇒ Object
21 22 23 |
# File 'lib/osctld/assets/validator.rb', line 21 def add_assets(new_assets) assets.concat(new_assets) end |
#validate ⇒ Array<Asset::Base>
Validate and return assets
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/osctld/assets/validator.rb', line 27 def validate dataset_hash = {} property_hash = {} assets.each do |asset| datasets, properties = asset.prefetch_zfs datasets.each do |ds| dataset_hash[ds] = true end properties.each do |p| property_hash[p] = true end end propreader = OsCtl::Lib::Zfs::PropertyReader.new tree = propreader.read( dataset_hash.keys, property_hash.keys, recursive: false, ignore_error: true ) run = Run.new(tree) assets.each do |asset| asset.send(:run_validation, run) end assets end |