Permalink
Browse files

cleaning up criteria

  • Loading branch information...
antonrogov committed Sep 1, 2011
1 parent 688430d commit 5f5fdd50ec594e5597578bd867de62a79f513580
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/sunspot/mongoid.rb
View
@@ -32,13 +32,18 @@ def id
class DataAccessor < Sunspot::Adapters::DataAccessor
def load(id)
- @clazz.find(BSON::ObjectID.from_string(id)) rescue nil
+ criteria(id).first
end
def load_all(ids)
- @clazz.where(:_id.in => ids.map { |id| BSON::ObjectId.from_string(id) })
+ criteria(ids)
+ end
+
+ private
+
+ def criteria(id)
+ @clazz.criteria.id(id)
end
-
end
end
end

0 comments on commit 5f5fdd5

Please sign in to comment.