Module: PluckyMethods::ClassMethods
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mongo_mapper/plugins/identity_map.rb
Instance Method Summary collapse
Instance Method Details
#find_each(opts = {}) ⇒ Object
135 136 137 138 139 140 141 142 143 |
# File 'lib/mongo_mapper/plugins/identity_map.rb', line 135 def find_each(opts={}) return super if !block_given? query = clone.amend(opts) super(opts) do |doc| doc.remove_from_identity_map if doc && query.fields? yield doc end end |
#find_one(opts = {}) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/mongo_mapper/plugins/identity_map.rb', line 123 def find_one(opts={}) query = clone.amend(opts) if identity_map && query.simple? && (document = identity_map.get_from_identity_map(query[:_id])) document else super.tap do |doc| doc.remove_from_identity_map if doc && query.fields? end end end |