Method: Wayback::Base.fetch_or_new

Defined in:
lib/wayback/base.rb

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

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

Parameters:

  • attrs (Hash) (defaults to: {})

Returns:



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

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