Module: Mongoid::SleepingKingStudios::Orderable::ClassMethods
- Defined in:
- lib/mongoid/sleeping_king_studios/orderable.rb
Overview
Class methods added to the base class via #extend.
Instance Method Summary collapse
-
#cache_ordering(sort_params, options = {}) ⇒ Object
Creates the order field and sets up the callbacks and helpers.
-
#reorder_ordering_name! ⇒ Object
Iterates through the entire collection and sets the cached order of each item to its current order index.
Instance Method Details
#cache_ordering(sort_params, options = {}) ⇒ Object
173 174 175 176 |
# File 'lib/mongoid/sleeping_king_studios/orderable.rb', line 173 def cache_ordering *sort_params, ** concern = Mongoid::SleepingKingStudios::Orderable concern.apply self, sort_params, end |
#reorder_ordering_name! ⇒ Object
Iterates through the entire collection and sets the cached order of each item to its current order index. Filtered items have their order set to nil. Normally, this should be taken care of when the items are saved, but this method allows the process to be reset in case of data corruption or other issues.
The generated name of this method will depend on the sort params or the :as option provided. For example, :as => :alphabetical_order will result in a class method ::reorder_alphabetical!.
|
# File 'lib/mongoid/sleeping_king_studios/orderable.rb', line 178
|