Module: MongoMapper::Plugins::IdentityMap::ClassMethods::IdentityMapQueryMethods
- Defined in:
- lib/mongo_mapper/plugins/identity_map.rb
Instance Method Summary collapse
Instance Method Details
#all(opts = {}) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/mongo_mapper/plugins/identity_map.rb', line 61 def all(opts={}) query = clone.amend(opts) super.tap do |docs| model.remove_documents_from_map(docs) if query.fields? end end |
#find_each(opts = {}, &block) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/mongo_mapper/plugins/identity_map.rb', line 80 def find_each(opts={}, &block) query = clone.amend(opts) super(opts) do |doc| model.remove_documents_from_map(doc) if query.fields? block.call(doc) unless block.nil? end end |
#find_one(opts = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/mongo_mapper/plugins/identity_map.rb', line 68 def find_one(opts={}) query = clone.amend(opts) if IdentityMap.enabled? && query.simple? && (document = model.get_from_identity_map(query[:_id])) document else super.tap do |doc| model.remove_documents_from_map(doc) if query.fields? end end end |