class Terrestrial::IdentityMap

Attributes

storage[R]

Public Class Methods

new(storage) click to toggle source
# File lib/terrestrial/identity_map.rb, line 3
def initialize(storage)
  @storage = storage
end

Public Instance Methods

call(mapping, record, object) click to toggle source
# File lib/terrestrial/identity_map.rb, line 10
def call(mapping, record, object)
  storage.fetch(hash_key(mapping, record)) {
    storage.store(hash_key(mapping, record), object)
  }
end

Private Instance Methods

hash_key(mapping, record) click to toggle source
# File lib/terrestrial/identity_map.rb, line 18
def hash_key(mapping, record)
  [mapping.name, record.namespace, record.identity]
end