class Perpetuity::IdentityMap

Public Class Methods

new() click to toggle source
# File lib/perpetuity/identity_map.rb, line 3
def initialize
  @map = Hash.new { |hash, key| hash[key] = {} }
end

Public Instance Methods

<<(object) click to toggle source
# File lib/perpetuity/identity_map.rb, line 11
def << object
  klass = object.class
  id = object.instance_variable_get(:@id)
  @map[klass][id] = object
end
[](klass, id) click to toggle source
# File lib/perpetuity/identity_map.rb, line 7
def [] klass, id
  @map[klass][id]
end
ids_for(klass) click to toggle source
# File lib/perpetuity/identity_map.rb, line 17
def ids_for klass
  @map[klass].keys
end