Class: Ari::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/ari/model.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Model

Returns a new instance of Model.


6
7
8
9
10
11
# File 'lib/ari/model.rb', line 6

def initialize(attributes)
  if attributes
    @client = attributes.delete(:client)
    self.attributes = attributes
  end
end

Instance Method Details

#attributes=(attributes) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ari/model.rb', line 13

def attributes=(attributes)
  attributes.each do |name, value|
    setter = "#{name}="
    if respond_to? setter
      value.merge!(client: @client) if @client && value.is_a?(Hash)
      __send__ setter, value
    else
      instance_variable_set "@#{name}", value
    end
  end
end