module Babik::QuerySet::Sortable

Sort functionality of QuerySet

Public Instance Methods

disorder!() click to toggle source

Remove the order on this QuerySet according to an order @return [QuerySet] reference to this QuerySet.

# File lib/babik/queryset/mixins/sortable.rb, line 19
def disorder!
  @_order = nil
  self
end
invert_order!() click to toggle source

Invert the order e.g.

first_name ASC, last_name ASC, created_at DESC => invert => first_name DESC, last_name DESC, created_at ASC

@return [QuerySet] reference to this QuerySet.

# File lib/babik/queryset/mixins/sortable.rb, line 36
def invert_order!
  @_order.invert!
  self
end
order!(*order) click to toggle source

Alias for order_by @see order_by @param order [Array, String, Hash] ordering that will be applied to the QuerySet. @return [QuerySet] reference to this QuerySet.

# File lib/babik/queryset/mixins/sortable.rb, line 28
def order!(*order)
  order_by!(*order)
end
order_by!(*order) click to toggle source

Sort QuerySet according to an order @param order [Array, String, Hash] ordering that will be applied to the QuerySet.

See {Babik::QuerySet::Order#order_by}.

@return [QuerySet] reference to this QuerySet.

# File lib/babik/queryset/mixins/sortable.rb, line 12
def order_by!(*order)
  @_order = Babik::QuerySet::Order.new(@model, *order)
  self
end
ordered?() click to toggle source

Inform if there is an order for this QuerySet @return [Boolean] True if this QuerySet is ordered, false otherwise.

# File lib/babik/queryset/mixins/sortable.rb, line 43
def ordered?
  return true if @_order
  false
end