Module: LegacyFacter::Core::Suitable
- Included in:
- Facter::Core::Aggregate, Facter::Util::Resolution
- Defined in:
- lib/facter/custom_facts/core/suitable.rb
Instance Method Summary collapse
-
#confine(confines = nil, &block) ⇒ void
Sets the conditions for this resolution to be used.
-
#has_weight(weight) ⇒ void
Sets the weight of this resolution.
-
#suitable? ⇒ Boolean
private
Is this resolution mechanism suitable on the system in question?.
-
#weight ⇒ Integer
private
Returns the importance of this resolution.
Instance Method Details
#confine(confines) ⇒ void #confine(confines, &block) {|value| ... } ⇒ void #confine(&block) ⇒ void
This method returns an undefined value.
Sets the conditions for this resolution to be used. This method accepts multiple forms of arguments to determine suitability.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/facter/custom_facts/core/suitable.rb', line 74 def confine(confines = nil, &block) case confines when Hash confines.each do |fact, values| @confines.push LegacyFacter::Util::Confine.new(fact, *values) end else if block if confines @confines.push LegacyFacter::Util::Confine.new(confines, &block) else @confines.push LegacyFacter::Util::Confine.new(&block) end end end end |
#has_weight(weight) ⇒ void
This method returns an undefined value.
Sets the weight of this resolution. If multiple suitable resolutions are found, the one with the highest weight will be used. If weight is not given, the number of confines set on a resolution will be used as its weight (so that the most specific resolution is used).
21 22 23 24 |
# File 'lib/facter/custom_facts/core/suitable.rb', line 21 def has_weight(weight) @weight = weight self end |
#suitable? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Is this resolution mechanism suitable on the system in question?
105 106 107 |
# File 'lib/facter/custom_facts/core/suitable.rb', line 105 def suitable? @confines.all?(&:true?) end |
#weight ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the importance of this resolution. If the weight was not given, the number of confines is used instead (so that a more specific resolution wins over a less specific one).
98 99 100 |
# File 'lib/facter/custom_facts/core/suitable.rb', line 98 def weight @weight || @confines.length end |