Class: Facter::Core::Aggregate
- Inherits:
-
Object
- Object
- Facter::Core::Aggregate
- Defined in:
- lib/facter/custom_facts/core/aggregate.rb
Overview
Defined Under Namespace
Classes: DependencyError
Instance Attribute Summary collapse
-
#confines ⇒ Array<LegacyFacter::Core::Confine>
readonly
private
An array of confines restricting this to a specific platform.
- #deps ⇒ LegacyFacter::Core::DirectedGraph readonly private
- #fact ⇒ Facter::Util::Fact readonly private
-
#name ⇒ Symbol
readonly
The name of the aggregate resolution.
Attributes included from LegacyFacter::Core::Resolvable
Instance Method Summary collapse
-
#<=>(other) ⇒ bool
private
Compares the weight of two aggregate facts.
-
#aggregate {|Hash<Symbol, Object>| ... } ⇒ Facter::Core::Aggregate
Define how all chunks should be combined.
-
#chunk(name, opts = {}, &block) ⇒ Facter::Core::Aggregate
Define a new chunk for the given aggregate.
-
#evaluate(&block) ⇒ String
private
Evaluates the given block.
-
#initialize(name, fact) ⇒ Aggregate
constructor
A new instance of Aggregate.
-
#options(options) ⇒ nil
private
Sets options for the aggregate fact.
-
#resolution_type ⇒ Symbol
private
Returns the fact’s resolution type.
Methods included from LegacyFacter::Core::Resolvable
#flush, #limit, #on_flush, #value
Methods included from LegacyFacter::Core::Suitable
#confine, #has_weight, #suitable?, #weight
Constructor Details
#initialize(name, fact) ⇒ Aggregate
Returns a new instance of Aggregate.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 49 def initialize(name, fact) @name = name @fact = fact @confines = [] @chunks = {} @aggregate = nil @deps = LegacyFacter::Core::DirectedGraph.new end |
Instance Attribute Details
#confines ⇒ Array<LegacyFacter::Core::Confine> (readonly)
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 An array of confines restricting this to a specific platform.
40 41 42 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 40 def confines @confines end |
#deps ⇒ LegacyFacter::Core::DirectedGraph (readonly)
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.
32 33 34 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 32 def deps @deps end |
#fact ⇒ Facter::Util::Fact (readonly)
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.
47 48 49 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 47 def fact @fact end |
#name ⇒ Symbol (readonly)
Returns The name of the aggregate resolution.
25 26 27 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 25 def name @name end |
Instance Method Details
#<=>(other) ⇒ bool
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.
Compares the weight of two aggregate facts
65 66 67 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 65 def <=>(other) weight <=> other.weight end |
#aggregate {|Hash<Symbol, Object>| ... } ⇒ Facter::Core::Aggregate
Define how all chunks should be combined
151 152 153 154 155 156 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 151 def aggregate(&block) raise ArgumentError, "#{self.class.name}#aggregate requires a block" unless block_given? @aggregate = block self end |
#chunk(name, opts = {}, &block) ⇒ Facter::Core::Aggregate
Define a new chunk for the given aggregate
111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 111 def chunk(name, opts = {}, &block) evaluate_params(name, &block) deps = Array(opts.delete(:require)) unless opts.empty? raise ArgumentError, "Unexpected options passed to #{self.class.name}#chunk: #{opts.keys.inspect}" end @deps[name] = deps @chunks[name] = block self end |
#evaluate(&block) ⇒ String
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.
Evaluates the given block
87 88 89 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 87 def evaluate(&block) instance_eval(&block) end |
#options(options) ⇒ nil
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.
Sets options for the aggregate fact
74 75 76 77 78 79 80 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 74 def () = %i[name timeout weight fact_type] .each do |option_name| instance_variable_set("@#{option_name}", .delete(option_name)) if .key?(option_name) end raise ArgumentError, "Invalid aggregate options #{.keys.inspect}" unless .keys.empty? end |
#resolution_type ⇒ Symbol
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 fact’s resolution type
163 164 165 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 163 def resolution_type :aggregate end |