class Filterparams::OrderExtractor
Constants
- ORDER_MATCHER
Public Class Methods
new(orders)
click to toggle source
# File lib/filterparams/order_extractor.rb, line 10 def initialize(orders) orders = [orders] unless orders.is_a? Array @orders = orders end
Public Instance Methods
orders()
click to toggle source
# File lib/filterparams/order_extractor.rb, line 16 def orders @order_objs ||= extract_orders end
Private Instance Methods
extract_orders()
click to toggle source
# File lib/filterparams/order_extractor.rb, line 22 def extract_orders @orders.map { |order| generate_order(order) } .reject(&:nil?) end
generate_order(order_string)
click to toggle source
# File lib/filterparams/order_extractor.rb, line 27 def generate_order(order_string) match = ORDER_MATCHER.match(order_string) return nil if match.nil? if match['param'].nil? direction = match['direction'] name = match['directed_param'] else direction = 'asc' name = match['param'] end Filterparams::Order.new(name, direction == 'desc') end