Class: ChefCLI::Policyfile::AttributeMergeChecker
- Inherits:
-
Object
- Object
- ChefCLI::Policyfile::AttributeMergeChecker
- Defined in:
- lib/chef-cli/policyfile/attribute_merge_checker.rb
Defined Under Namespace
Classes: AttributeHashInfo, ConflictError, Leaf
Instance Attribute Summary collapse
-
#attribute_hash_infos ⇒ Array<AttributeHashInfo>
readonly
A list of attributes and who they were provided by.
Instance Method Summary collapse
-
#check! ⇒ Object
Check all added attributes for conflicts.
-
#initialize ⇒ AttributeMergeChecker
constructor
A new instance of AttributeMergeChecker.
-
#with_attributes(source_name, hash) ⇒ Object
Add a hash of attributes to the set of attributes that will be compared for conflicts.
Constructor Details
#initialize ⇒ AttributeMergeChecker
Returns a new instance of AttributeMergeChecker.
62 63 64 |
# File 'lib/chef-cli/policyfile/attribute_merge_checker.rb', line 62 def initialize @attribute_hash_infos = [] end |
Instance Attribute Details
#attribute_hash_infos ⇒ Array<AttributeHashInfo> (readonly)
Returns A list of attributes and who they were provided by.
60 61 62 |
# File 'lib/chef-cli/policyfile/attribute_merge_checker.rb', line 60 def attribute_hash_infos @attribute_hash_infos end |
Instance Method Details
#check! ⇒ Object
Check all added attributes for conflicts. Different sources can provide the same attribute if they have the same value. Otherwise, it is considered a conflict
80 81 82 83 84 85 |
# File 'lib/chef-cli/policyfile/attribute_merge_checker.rb', line 80 def check! check_struct = Mash.new attribute_hash_infos.each do |attr_hash_info| fill!(check_struct, attr_hash_info.source_name, "", attr_hash_info.hash) end end |
#with_attributes(source_name, hash) ⇒ Object
Add a hash of attributes to the set of attributes that will be compared for conflicts
71 72 73 |
# File 'lib/chef-cli/policyfile/attribute_merge_checker.rb', line 71 def with_attributes(source_name, hash) attribute_hash_infos << AttributeHashInfo.new(source_name, hash) end |