Module: Babik::QuerySet::Sortable
- Included in:
- AbstractBase
- Defined in:
- lib/babik/queryset/mixins/sortable.rb
Overview
Sort functionality of QuerySet
Instance Method Summary collapse
-
#disorder! ⇒ QuerySet
Remove the order on this QuerySet according to an order.
-
#invert_order! ⇒ QuerySet
Invert the order e.g.
-
#order!(*order) ⇒ QuerySet
Alias for order_by.
-
#order_by!(*order) ⇒ QuerySet
Sort QuerySet according to an order.
-
#ordered? ⇒ Boolean
Inform if there is an order for this QuerySet.
Instance Method Details
#disorder! ⇒ QuerySet
Remove the order on this QuerySet according to an order
19 20 21 22 |
# File 'lib/babik/queryset/mixins/sortable.rb', line 19 def disorder! @_order = nil self end |
#invert_order! ⇒ QuerySet
Invert the order e.g.
first_name ASC, last_name ASC, created_at DESC => invert => first_name DESC, last_name DESC, created_at ASC
36 37 38 39 |
# File 'lib/babik/queryset/mixins/sortable.rb', line 36 def invert_order! @_order.invert! self end |
#order!(*order) ⇒ QuerySet
Alias for order_by
28 29 30 |
# File 'lib/babik/queryset/mixins/sortable.rb', line 28 def order!(*order) order_by!(*order) end |
#order_by!(*order) ⇒ QuerySet
Sort QuerySet according to an order
12 13 14 15 |
# File 'lib/babik/queryset/mixins/sortable.rb', line 12 def order_by!(*order) @_order = Babik::QuerySet::Order.new(@model, *order) self end |
#ordered? ⇒ Boolean
Inform if there is an order for this QuerySet
43 44 45 46 |
# File 'lib/babik/queryset/mixins/sortable.rb', line 43 def ordered? return true if @_order false end |