module Mongoid::Ordering::ClassMethods

Public Instance Methods

ordered(options = {}) click to toggle source

Sets options used for ordering.

@example Set options.

class Book
  include Mongoid::Document
  include Mongoid::Ordering

  belongs_to :author

  ordered scope: :author
end

@param [ Hash ] options The options.

@option options [ Array<Symbol>, Symbol ] scope One or more relations or

attributes that will determine the scope within which to keep the
documents in order.
# File lib/mongoid/ordering.rb, line 44
def ordered(options = {})
  self.default_sibling_scope = self.ordering_scopes = Array.wrap(options[:scope]).compact
end