class TableSortable::Column::Sorter
Attributes
sort_order[RW]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
TableSortable::Concerns::Proc::new
# File lib/table_sortable/column/sorter.rb, line 8 def initialize(*args) super :sort, *args end
Public Instance Methods
active_record_proc()
click to toggle source
# File lib/table_sortable/column/sorter.rb, line 16 def active_record_proc -> (sort_order, col=nil) { order(col.name.to_s.underscore => sort_order) } end
array_proc()
click to toggle source
# File lib/table_sortable/column/sorter.rb, line 12 def array_proc -> (sort_order, col=nil) { sort{ |a,b| col.value(sort_order == :asc ? a : b) <=> col.value(sort_order == :asc ? b : a) } } end
proc_wrapper(proc)
click to toggle source
# File lib/table_sortable/column/sorter.rb, line 20 def proc_wrapper(proc) -> (sort_order, col=nil) { instance_exec(sort_order , &proc) } end
run(records)
click to toggle source
# File lib/table_sortable/column/sorter.rb, line 24 def run(records) records.instance_exec(sort_order, column, &proc) end
used?()
click to toggle source
# File lib/table_sortable/column/sorter.rb, line 28 def used? !sort_order.nil? end