def add(name, options = {}, &block)
name = canonize(name)
unless fact = @facts[name]
fact = Facter::Util::Fact.new(name)
@facts[name] = fact
end
options.each do |opt, value|
method = opt.to_s + "="
if fact.respond_to?(method)
fact.send(method, value)
options.delete(opt)
end
end
if block_given? and resolve = fact.add(&block)
options.each do |opt, value|
method = opt.to_s + "="
if resolve.respond_to?(method)
resolve.send(method, value)
options.delete(opt)
end
end
end
unless options.empty?
raise ArgumentError, "Invalid facter option(s) %s" % options.keys.collect { |k| k.to_s }.join(",")
end
return fact
end