Permalink
Browse files

Refactored checking of fields being selected to method.

  • Loading branch information...
1 parent 794c687 commit 8b41bd7fcf48a68c4b81cbf8307043361326d2f8 @jnunemaker jnunemaker committed Jan 23, 2010
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/mongo_mapper/plugins/identity_map.rb
@@ -30,15 +30,15 @@ def find_one(options={})
identity_map[criteria[:_id]]
else
super.tap do |document|
- remove_documents_from_map(document) unless finder_options[:fields].nil?
+ remove_documents_from_map(document) if selecting_fields?(finder_options)
end
end
end
def find_many(options)
criteria, finder_options = to_finder_options(options)
super.tap do |documents|
- remove_documents_from_map(documents) unless finder_options[:fields].nil?
+ remove_documents_from_map(documents) if selecting_fields?(finder_options)
end
end
@@ -90,6 +90,10 @@ def remove_documents_from_map(*documents)
def simple_find?(criteria)
criteria.keys == [:_id] || criteria.keys.to_set == [:_id, :_type].to_set
end
+
+ def selecting_fields?(options)
+ !options[:fields].nil?
+ end
end
module InstanceMethods

0 comments on commit 8b41bd7

Please sign in to comment.