Method: Mongoid::Threaded#disable_identity_map

Defined in:
lib/mongoid/threaded.rb

#disable_identity_map(option) ⇒ Object

Disable the identity map on either the current thread or all threads.

Examples:

Disable the identity map on all threads.

Threaded.disable_identity_map(:all)

Disable the identity map on the current thread.

Threaded.disable_identity_map(:current)

Parameters:

  • option (Symbol)

    The disabling option.

Since:

  • 3.0.0



203
204
205
206
207
208
209
210
211
# File 'lib/mongoid/threaded.rb', line 203

def disable_identity_map(option)
  if option == :all
    Thread.list.each do |thread|
      thread["[mongoid]:identity-map-enabled"] = false
    end
  else
    Thread.current["[mongoid]:identity-map-enabled"] = false
  end
end