class Facter::FactCollection

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/facter/models/fact_collection.rb, line 4
def initialize
  super
end

Public Instance Methods

build_fact_collection!(facts) click to toggle source
# File lib/facter/models/fact_collection.rb, line 8
def build_fact_collection!(facts)
  facts.each do |fact|
    next if %i[core legacy].include?(fact.type) && fact.value.nil?

    bury_fact(fact)
  end

  self
end
bury(*args) click to toggle source
# File lib/facter/models/fact_collection.rb, line 24
def bury(*args)
  raise ArgumentError, '2 or more arguments required' if args.count < 2

  if args.count == 2
    self[args[0]] = args[1]
  else
    arg = args.shift
    self[arg] = FactCollection.new unless self[arg]
    self[arg].bury(*args) unless args.empty?
  end

  self
end
value(*keys) click to toggle source
# File lib/facter/models/fact_collection.rb, line 18
def value(*keys)
  keys.reduce(self) do |memo, key|
    memo.fetch(key.to_s)
  end
end

Private Instance Methods

bury_fact(fact) click to toggle source
# File lib/facter/models/fact_collection.rb, line 40
def bury_fact(fact)
  bury(*fact.name.split('.') + fact.filter_tokens << fact.value)
end