module Paginative::OrderingHelpers
Public Class Methods
sanitized_ordering(table_name, fields, order)
click to toggle source
# File lib/paginative/models/ordering_helpers.rb, line 6 def self.sanitized_ordering(table_name, fields, order) fields.map do |field| "#{field} #{sanitize_column_direction(order)}" end.join(', ') end
Private Class Methods
sanitize_column_direction(direction)
click to toggle source
# File lib/paginative/models/ordering_helpers.rb, line 14 def self.sanitize_column_direction(direction) direction = direction.upcase ['DESC', 'ASC'].include?(direction) ? direction : "ASC" end