Method: Furnish::Provisioner::API#initialize

Defined in:
lib/furnish/provisioners/api.rb

#initialize(args = {}) ⇒ API

Default constructor. If given arguments, must be of type Hash, keys are the name of furnish properties. Raises ArgumentError if no furnish property exists, or the type of the value provided is not a kind of type specified in the property. See API.furnish_property for more information.

Does nothing more, not required anywhere in furnish itself – you may redefine this constructor and work against completely differently input and behavior, or call this as a superclass initializer and then do your work.



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/furnish/provisioners/api.rb', line 275

def initialize(args={})
  unless args.kind_of?(Hash)
    raise ArgumentError, "Arguments must be a kind of hash"
  end

  args.each do |k, v|
    props = self.class.furnish_properties

    if props.has_key?(k)
      if v.kind_of?(props[k][:type])
        send("#{k}=", v)
      else
        raise ArgumentError, "Value for furnish property #{k} on #{self.class.name} does not match type #{props[k][:type]}"
      end
    else
      raise ArgumentError, "Invalid argument #{k}, not a furnish property for #{self.class.name}"
    end
  end
end