Method: IGMarkets::Model#initialize

Defined in:
lib/ig_markets/model.rb

#initialize(attributes = {}) ⇒ Model

Initializes this new model with the given attribute values. Attributes not known to this model will raise ArgumentError.

Parameters:

  • (defaults to: {})

    The attribute values to set on this new model.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ig_markets/model.rb', line 15

def initialize(attributes = {})
  self.class.defined_attribute_names.each do |name|
    send "#{name}=", attributes[name]
  end

  attributes.each do |name, value|
    next if respond_to? "#{name}="

    raise ArgumentError, "unknown attribute: #{self.class.name}##{name}, value: #{inspect_value value}"
  end
end