16: def add(name, options = {}, &block)
17: name = canonize(name)
18:
19: unless fact = @facts[name]
20: fact = Facter::Util::Fact.new(name)
21:
22: @facts[name] = fact
23: end
24:
25:
26: options.each do |opt, value|
27: method = opt.to_s + "="
28: if fact.respond_to?(method)
29: fact.send(method, value)
30: options.delete(opt)
31: end
32: end
33:
34: if block_given? and resolve = fact.add(&block)
35:
36: options.each do |opt, value|
37: method = opt.to_s + "="
38: if resolve.respond_to?(method)
39: resolve.send(method, value)
40: options.delete(opt)
41: end
42: end
43: end
44:
45: unless options.empty?
46: raise ArgumentError, "Invalid facter option(s) %s" % options.keys.collect { |k| k.to_s }.join(",")
47: end
48:
49: return fact
50: end