class Parelation::Criteria::Order

Constants

ORDER_FORMAT

@return [Regexp] The order format.

Public Class Methods

match?(param) click to toggle source

@param param [String] @return [TrueClass, FalseClass]

# File lib/parelation/criteria/order.rb, line 12
def self.match?(param)
  !!param.match(ORDER_FORMAT)
end

Public Instance Methods

call() click to toggle source

Applies the specified orderings to {#chain}.

@return [ActiveRecord::Relation] the modified chain.

# File lib/parelation/criteria/order.rb, line 20
def call
  orders.inject(chain) do |chain, order|
    chain.order(order.criteria)
  end
end

Private Instance Methods

orders() click to toggle source

@return [Array<Parelation::Criteria::Order::Object>] an

array of attributes to order.
# File lib/parelation/criteria/order.rb, line 31
def orders
  @orders ||= [value].flatten.map do |order|
    Object.new(order)
  end
end