Module: RFacter::Core::Suitable Private
- Included in:
- Aggregate, Util::Resolution
- Defined in:
- lib/rfacter/core/suitable.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
The Suitable mixin provides mechanisms for confining objects to run on certain platforms and determining the run precedence of these objects.
Classes that include the Suitable mixin should define a ‘#confines` method that returns an Array of zero or more Util::Confine objects.
Instance Attribute Summary collapse
-
#weight ⇒ Integer
private
Returns the importance of this resolution.
Instance Method Summary collapse
-
#confine(confines = nil, &block) ⇒ void
private
Sets the conditions for this resolution to be used.
-
#has_weight(weight) ⇒ void
private
Sets the weight of this resolution.
-
#suitable? ⇒ Boolean
private
Is this resolution mechanism suitable on the system in question?.
Instance Attribute Details
#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).
97 98 99 100 101 102 103 |
# File 'lib/rfacter/core/suitable.rb', line 97 def weight if @weight @weight else @confines.length end end |
Instance Method Details
#confine(confines) ⇒ void #confine(confines, &block) {|value| ... } ⇒ void #confine(&block) ⇒ void
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.
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 90 |
# File 'lib/rfacter/core/suitable.rb', line 74 def confine(confines = nil, &block) case confines when Hash confines.each do |fact, values| @confines.push RFacter::Util::Confine.new(fact, *values) end else if block if confines @confines.push RFacter::Util::Confine.new(confines, &block) else @confines.push RFacter::Util::Confine.new(&block) end else end end end |
#has_weight(weight) ⇒ void
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.
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).
24 25 26 |
# File 'lib/rfacter/core/suitable.rb', line 24 def has_weight(weight) @weight = weight 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?
106 107 108 |
# File 'lib/rfacter/core/suitable.rb', line 106 def suitable? @confines.all? { |confine| confine.true? } end |