Method: Wayback::Base.fetch

Defined in:
lib/wayback/base.rb

.fetch(attrs) ⇒ Wayback::Base

Retrieves an object from the identity map.

Parameters:

  • attrs (Hash)

Returns:

Raises:



34
35
36
37
38
39
40
41
# File 'lib/wayback/base.rb', line 34

def self.fetch(attrs)
  return unless identity_map
  if object = identity_map.fetch(Marshal.dump(attrs))
    return object
  end
  return yield if block_given?
  raise Wayback::Error::IdentityMapKeyError, "key not found"
end