Method: Codat::BaseModel#initialize

Defined in:
lib/codat/base_model.rb

#initialize(json: {}, key_transformer: Camelizer) ⇒ BaseModel

Sets all the instance variables by reading the JSON from Codat and converting the keys from camelCase to snake_case, as it’s the standard in Ruby.



52
53
54
55
56
# File 'lib/codat/base_model.rb', line 52

def initialize(json: {}, key_transformer: Camelizer)
  self.class.attributes.each do |attr|
    send("#{attr}=", json[key_transformer.transform(attr)])
  end
end