Method: Mongoid::Criterion::Optional#ascending
- Defined in:
- lib/mongoid/criterion/optional.rb
#ascending(*fields) ⇒ Criteria Also known as: asc
Adds fields to be sorted in ascending order. Will add them in the order they were passed into the method.
16 17 18 19 20 21 |
# File 'lib/mongoid/criterion/optional.rb', line 16 def ascending(*fields) clone.tap do |crit| crit.[:sort] = [] unless [:sort] || fields.first.nil? fields.flatten.each { |field| (crit.[:sort], [ field, :asc ]) } end end |