Class: Queryko::Filters::Order

Inherits:
Base
  • Object
show all
Defined in:
lib/queryko/filters/order.rb

Instance Attribute Summary

Attributes inherited from Base

#as, #column_name, #feature, #field, #query_object, #table_name

Instance Method Summary collapse

Methods inherited from Base

#call, #initialize

Constructor Details

This class inherits a constructor from Queryko::Filters::Base

Instance Method Details

#filter_input(token) ⇒ Object



9
10
11
12
# File 'lib/queryko/filters/order.rb', line 9

def filter_input(token)
  return 'DESC' if token.to_s.downcase == 'desc'
  return 'ASC'
end

#param_key_formatObject



14
15
16
# File 'lib/queryko/filters/order.rb', line 14

def param_key_format
  "order_by_#{column_name}"
end

#perform(collection, token, query_object = nil) ⇒ Object



5
6
7
# File 'lib/queryko/filters/order.rb', line 5

def perform(collection, token, query_object = nil)
  collection.order("#{table_name}.#{column_name} #{filter_input(token)}", )
end