Sha256: 579e3f1b196f65cd6befddc08b0338c109c6a5bc1844849f4cecf5514cbd4dfc

Contents?: true

Size: 434 Bytes

Versions: 3

Compression:

Stored size: 434 Bytes

Contents

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

    attr_reader :storage
    private     :storage

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

    private

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
terrestrial-0.5.0 lib/terrestrial/identity_map.rb
terrestrial-0.3.0 lib/terrestrial/identity_map.rb
terrestrial-0.1.1 lib/terrestrial/identity_map.rb