lib/onering/util.rb in onering-client-0.0.79 vs lib/onering/util.rb in onering-client-0.0.80

- old
+ new

@@ -89,28 +89,32 @@ def fact(name, default=nil) name = name.to_s if defined?(Facter) - fact = Facter.value(name) + if name.downcase == 'all' + return Facter.to_hash + else + fact = Facter.value(name) - # short circuit nil responses - return default if fact.nil? + # short circuit nil responses + return default if fact.nil? - # if we are asking for a nested object... - if name.include?('.') - # ...and the response IS an object... - if fact.is_a?(Hash) - # remove the first part and return the rest - name = name.sub(/^[^\.]+\./,'') - return fact.get(name, default) + # if we are asking for a nested object... + if name.include?('.') + # ...and the response IS an object... + if fact.is_a?(Hash) + # remove the first part and return the rest + name = name.sub(/^[^\.]+\./,'') + return fact.get(name, default) + else + # not an object, return default + return default + end else - # not an object, return default - return default + # this is a simple request, return the fact + return fact end - else - # this is a simple request, return the fact - return fact end end return default end \ No newline at end of file