Module: Opera::MobileStoreSDK::IdentityMapable

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#initialize(params = {}) ⇒ Object

Registers itself in the identity map:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/opera/mobile_store_sdk/identity_mapable.rb', line 8

def initialize(params={})
  super

  # Upsert in the identity map:
  if self.class.identity_map.key? self.id
    params.each do |field_name, field_value|
      self.class.identity_map[self.id].public_send(
        "#{field_name}=", field_value
      )
    end
  else
    self.class.identity_map[self.id] = self
  end
end