Module: ActiveRecord::Base::ThreadIdentityMap::ClassMethods

Included in:
ActiveRecord::Base
Defined in:
lib/identity_map/cache.rb

Instance Method Summary collapse

Instance Method Details

#create_identity_mapObject



41
42
43
# File 'lib/identity_map/cache.rb', line 41

def create_identity_map
  set_thread_id_map IdMap.new
end

#drop_identity_mapObject



45
46
47
# File 'lib/identity_map/cache.rb', line 45

def drop_identity_map
  set_thread_id_map nil
end

#with_id_map(fresh = true) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/identity_map/cache.rb', line 49

def with_id_map( fresh = true)
  old = thread_id_map
  create_identity_map if fresh || old.nil?
  yield
ensure
  set_thread_id_map old
end

#without_id_mapObject



57
58
59
60
61
62
63
# File 'lib/identity_map/cache.rb', line 57

def without_id_map
  old = thread_id_map
  drop_identity_map
  yield
ensure
  set_thread_id_map old
end