class SequelMapper::IdentityMap

Attributes

storage[R]

Public Class Methods

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

Public Instance Methods

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

Private Instance Methods

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