Sha256: c9e4cc23984130c065f4fe1533325624e6dc1f9da5c285a2b0d76c985f1da7e2

Contents?: true

Size: 640 Bytes

Versions: 3

Compression:

Stored size: 640 Bytes

Contents

# frozen_string_literal: true

module Facter
  class FactCollection < Hash
    def initialize
      super
    end

    def build_fact_collection!(facts)
      facts.each do |fact|
        bury(*fact.name.split('.') + fact.filter_tokens << fact.value) unless fact.value.nil?
      end

      self
    end

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facter-4.0.9.pre lib/models/fact_collection.rb
facter-4.0.8.pre lib/models/fact_collection.rb
facter-4.0.7.pre lib/models/fact_collection.rb