Skip to content

Commit

Permalink
cleaning up criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
antonrogov committed Sep 1, 2011
1 parent 688430d commit 5f5fdd5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/sunspot/mongoid.rb
Expand Up @@ -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.