vendor/bundle/ruby/1.8/gems/facter-1.6.5/lib/facter/util/collection.rb
# Add a resolution mechanism for a named fact.  This does not distinguish
# between adding a new fact and adding a new way to resolve a fact.
Add a resolution mechanism for a named fact.  This does not distinguish
between adding a new fact and adding a new way to resolve a fact.
Add a resolution mechanism for a named fact . This does not distinguish between adding a new fact and adding a new way to resolve a fact .
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
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
Add a resolution mechanism for a named fact.
Add a resolution mechanism for a named fact .
# Set any fact-appropriate options. # If the resolve was actually added, set any resolve-appropriate options
name
options
block