Method: Playapi::Base.fetch_or_new

Defined in:
lib/playapi/base.rb

.fetch_or_new(attrs = {}) ⇒ Playapi::Base

Retrieves an object from the identity map, or stores it in the identity map if it doesn’t already exist.



64
65
66
67
68
69
70
71
72
# File 'lib/playapi/base.rb', line 64

def self.fetch_or_new(attrs={})
  return unless attrs
  return new(attrs) unless identity_map

  fetch(attrs) do
    object = new(attrs)
    store(object)
  end
end