lib/mongoid/finders.rb in mongoid-1.2.7 vs lib/mongoid/finders.rb in mongoid-1.2.8

- old
+ new

@@ -110,31 +110,13 @@ # # <tt>Person.max(:age)</tt> # # Returns: <tt>Float</tt> max value. def max(field) - Criteria.new(self).max(field) + criteria.max(field) end - # Will execute a +Criteria+ based on the +DynamicFinder+ that gets - # generated. - # - # Options: - # - # name: The finder method name - # args: The arguments to pass to the method. - # - # Example: - # - # <tt>Person.find_all_by_title_and_age("Sir", 30)</tt> - # def method_missing(name, *args) - # dyna = DynamicFinder.new(name, *args) - # finder, conditions = dyna.finder, dyna.conditions - # results = find(finder, :conditions => conditions) - # results ? results : dyna.create(self) - # end - # Convenience method for returning the min value of a field. # # Options: # # field: The field to use when calculating the min. @@ -143,11 +125,11 @@ # # <tt>Person.min(:age)</tt> # # Returns: <tt>Float</tt> min value. def min(field) - Criteria.new(self).min(field) + criteria.min(field) end # Find all documents in paginated fashion given the supplied arguments. # If no parameters are passed just default to offset 0 and limit 20. # @@ -177,11 +159,11 @@ # # <tt>Person.only(:field1, :field2, :field3)</tt> # # Returns: <tt>Criteria</tt> def only(*args) - Criteria.new(self).only(*args) + criteria.only(*args) end # Convenience method for returning the sum of a specified field for all # documents in the database. # @@ -193,11 +175,11 @@ # # <tt>Person.sum(:age)</tt> # # Returns: <tt>Float</tt> of the sum. def sum(field) - Criteria.new(self).sum(field) + criteria.sum(field) end # Entry point for creating a new criteria from a Document. This will # instantiate a new +Criteria+ object with the supplied select criterion # already added to it. @@ -210,10 +192,10 @@ # # <tt>Person.where(:field1 => "Value")</tt> # # Returns: <tt>Criteria</tt> def where(selector = nil) - Criteria.new(self).where(selector) + criteria.where(selector) end protected # Find the first object or create/initialize it. def find_or(method, attrs = {})