Module: Iord::Sort
Instance Method Summary collapse
Instance Method Details
#create_collection_with_sort ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/iord/sort.rb', line 59 def create_collection_with_sort if order_by create_collection_without_sort.order_by(order_by => sort_mode) else create_collection_without_sort end end |
#order_by ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/iord/sort.rb', line 40 def order_by if @order_by.nil? @order_by = params[:order_by] @order_by = nil unless resource_class.attribute_names.include? @order_by collection_url_defaults[:order_by] = @order_by if @order_by end return @order_by end |
#sort_mode ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/iord/sort.rb', line 49 def sort_mode if @sort_mode.nil? return @sort_mode = nil if order_by.nil? @sort_mode = (params[:sort_mode] || :asc).to_sym @sort_mode = :asc unless %i(asc desc).include? @sort_mode collection_url_defaults[:sort_mode] = @sort_mode end return @sort_mode end |