Method: Mongoid::UnitOfWork#unit_of_work
- Defined in:
- lib/mongoid/unit_of_work.rb
#unit_of_work(options = {}) ⇒ Object
We can process a unit of work in Mongoid and have the identity map automatically clear itself out after the work is complete.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mongoid/unit_of_work.rb', line 35 def unit_of_work( = {}) disable = [:disable] begin Threaded.disable_identity_map(disable) if disable yield if block_given? ensure if disable Threaded.enable_identity_map(disable) else IdentityMap.clear end end end |