Sha256: e4556f1b0b5238f6d2471b1d5e72f7b6b4d0ecc2f8ae3d5f6ba5fc9450f0e5dc
Contents?: true
Size: 950 Bytes
Versions: 15
Compression:
Stored size: 950 Bytes
Contents
require 'mongo_doc/criteria' module MongoDoc module Finders def self.extended(base) base.extend(Criteria) unless base === Criteria end # Find a +Document+ based on id (+String+ or +BSON::ObjectID+) # # <tt>Person.find('1')</tt> # <tt>Person.find(obj_id_1, obj_id_2)</tt> def find(*args) criteria.id(*args) end # # Find all +Document+s in the collections # # <tt>Person.find_all</tt> def find_all criteria end # Find a +Document+ based on id (+String+ or +BSON::ObjectID+) # or conditions # # <tt>Person.find_one('1')</tt> # <tt>Person.find_one(:conditions => {:age.gt => 25}, :order_by => [[:name, # :asc]])</tt> def find_one(conditions_or_id) if Hash === conditions_or_id Mongoid::Criteria.translate(self, conditions_or_id).one else Mongoid::Criteria.translate(self, conditions_or_id) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems