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 ⇒ Object readonly
- #deps ⇒ Object readonly
- #fact ⇒ Facter::Util::Fact readonly private
- #name ⇒ Object readonly
Attributes included from LegacyFacter::Core::Resolvable
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#aggregate {|Hash<Symbol, Object>| ... } ⇒ void
Define how all chunks should be combined.
-
#chunk(name, opts = {}) {|*Object| ... } ⇒ void
Define a new chunk for the given aggregate.
- #evaluate(&block) ⇒ Object
-
#initialize(name, fact) ⇒ Aggregate
constructor
A new instance of Aggregate.
- #options(options) ⇒ Object
- #resolution_type ⇒ Object
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.
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 40 def initialize(name, fact) @name = name @fact = fact @confines = [] @chunks = {} @aggregate = nil @deps = LegacyFacter::Core::DirectedGraph.new end |
Instance Attribute Details
#confines ⇒ Object (readonly)
33 34 35 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 33 def confines @confines end |
#deps ⇒ Object (readonly)
27 28 29 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 27 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.
38 39 40 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 38 def fact @fact end |
#name ⇒ Object (readonly)
22 23 24 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 22 def name @name end |
Instance Method Details
#<=>(other) ⇒ Object
51 52 53 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 51 def <=>(other) weight <=> other.weight end |
#aggregate {|Hash<Symbol, Object>| ... } ⇒ void
This method returns an undefined value.
Define how all chunks should be combined
128 129 130 131 132 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 128 def aggregate(&block) raise ArgumentError, "#{self.class.name}#aggregate requires a block" unless block_given? @aggregate = block end |
#chunk(name, opts = {}) {|*Object| ... } ⇒ void
This method returns an undefined value.
Define a new chunk for the given aggregate
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 89 def chunk(name, opts = {}, &block) raise ArgumentError, "#{self.class.name}#chunk requires a block" unless block_given? 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 end |
#evaluate(&block) ⇒ Object
63 64 65 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 63 def evaluate(&block) instance_eval(&block) end |
#options(options) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 55 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 ⇒ Object
134 135 136 |
# File 'lib/facter/custom_facts/core/aggregate.rb', line 134 def resolution_type :aggregate end |