Sha256: eee3bcb77b9f3bbfa51361efed540d62306b13a1f58349c0c8487d03afa60b3c

Contents?: true

Size: 349 Bytes

Versions: 4

Compression:

Stored size: 349 Bytes

Contents

module Nasty
  class IdentityMap
    def initialize(items = {})
      @items = items
    end

    def add(item)
      @items[item.id] = item
    end

    def has_item_for?(id)
      @items.has_key?(id)
    end

    def item_for(id)
      @items[id]
    end

    def evict(item)
      @items.reject! { |key, value| key == item.id }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nasty-0.0.1395464273 lib/nasty/identity_map.rb
nasty-0.0.1388168019 lib/nasty/identity_map.rb
nasty-0.0.1388167257 lib/nasty/identity_map.rb
nasty-0.0.1388166944 lib/nasty/identity_map.rb