Module: Outpost::Controller::Ordering

Extended by:
ActiveSupport::Concern
Defined in:
lib/outpost/controller/ordering.rb

Instance Method Summary collapse

Instance Method Details

#orderObject

Public: The order string to be passed into ActiveRecord

Examples

order
# => "updated_at DESC"

Returns String of the order.



41
42
43
# File 'lib/outpost/controller/ordering.rb', line 41

def order
  @order ||= "#{order_attribute} #{order_direction}"
end

#order_attributeObject

Public: The order that the records are currently sorted by. This gets passed directly to ActiveRecord, so it should be a valid database order.

Returns String of the order.



15
16
17
# File 'lib/outpost/controller/ordering.rb', line 15

def order_attribute
  @order_attribute ||= set_order_attribute
end

#order_directionObject

Public: The sort mode that the records are currently sorted by. This gets passed directory to ActiveRecord, so it should be a valid database sort mode.

Examples

order_direction
# => "ASC"

Returns String of the sort mode.



29
30
31
# File 'lib/outpost/controller/ordering.rb', line 29

def order_direction
  @order_direction ||= set_order_direction
end