class Nasty::IdentityMap
Public Class Methods
new(items = {})
click to toggle source
# File lib/nasty/identity_map.rb, line 3 def initialize(items = {}) @items = items end
Public Instance Methods
add(item)
click to toggle source
# File lib/nasty/identity_map.rb, line 7 def add(item) @items[item.id] = item end
evict(item)
click to toggle source
# File lib/nasty/identity_map.rb, line 19 def evict(item) @items.reject! { |key, value| key == item.id } end
has_item_for?(id)
click to toggle source
# File lib/nasty/identity_map.rb, line 11 def has_item_for?(id) @items.has_key?(id) end
item_for(id)
click to toggle source
# File lib/nasty/identity_map.rb, line 15 def item_for(id) @items[id] end