Method: Facter::FactCollection#value

Defined in:
lib/facter/models/fact_collection.rb

#value(user_query) ⇒ 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.

Collection#fetch implementation for nested collections.

Examples:

for fact_collection = { “os”: { “name”: “Darwin” } }

fact_collection.fetch("os.name") #=> "Darwin"


45
46
47
48
49
50
51
52
53
54
# File 'lib/facter/models/fact_collection.rb', line 45

def value(user_query)
  fetch(user_query) do
    split_user_query = Facter::Utils.split_user_query(user_query)
    split_user_query.reduce(self) do |memo, key|
      raise KeyError unless memo.respond_to?(:fetch)

      memo.fetch(key) { memo.fetch(key.to_s) }
    end
  end
end