module Mongoid::SleepingKingStudios::Orderable::ClassMethods
Class methods added to the base class via extend.
Public Instance Methods
cache_ordering(*sort_params, **options)
click to toggle source
@overload cache_ordering
sort_params, options = {}
Creates the order field and sets up the callbacks and helpers. @param [Array] sort_params The sort query used to order the collection. Accepts a subset of the options for a default Origin sort operation: - :field_name.desc, :another_field - { :field_name => -1, :another_field => 1 } - \[[:field_name, -1], [:another_field, :asc]] @param [Hash] options The options for the relation. @option options [Symbol] :as Sets the name of the generated field and helpers. By default, uses the name(s) and direction(s) of the fields from the sort query, e.g. :field_name_asc_another_field_desc_order. @option options [Hash] :filter Sets a filter that excludes collection items from the ordering process. Accepts the same parameters as a Mongoid #where query. @raise [Mongoid::Errors::InvalidOptions] If any of the provided options are invalid.
# File lib/mongoid/sleeping_king_studios/orderable.rb, line 188 def cache_ordering *sort_params, **options concern = Mongoid::SleepingKingStudios::Orderable concern.apply self, sort_params, options end