Sha256: 24f00f4d5a76375396d3a667e2a0a3fd4185c19d8f1acd6bac41797e2fcb06cc

Contents?: true

Size: 385 Bytes

Versions: 1

Compression:

Stored size: 385 Bytes

Contents

module SequelMapper
  class IdentityMap
    def initialize(storage)
      @storage = storage
    end

    attr_reader :storage
    private     :storage

    def call(record, object)
      storage.fetch(hash_key(record)) {
        storage.store(hash_key(record), object)
      }
    end

    private

    def hash_key(record)
      [record.namespace, record.identity]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sequel_mapper-0.0.3 lib/sequel_mapper/identity_map.rb