class TableSortable::Column::Filter
Attributes
collection[RW]
default_value[RW]
query[RW]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
TableSortable::Concerns::Proc::new
# File lib/table_sortable/column/filter.rb, line 8 def initialize(*args) options = args.extract_options! @default_value = options[:filter_initial_value] @collection = options[:filter_collection] super :filter, options end
Public Instance Methods
active_record_proc()
click to toggle source
# File lib/table_sortable/column/filter.rb, line 19 def active_record_proc -> (value, col=nil) { where("LOWER(#{col.name.to_s.underscore}) LIKE (?)", "%#{value.to_s.downcase}%") } end
array_proc()
click to toggle source
# File lib/table_sortable/column/filter.rb, line 15 def array_proc -> (value, col=nil) { select{|record| col.value(record).to_s.downcase.include? value.downcase} } end
proc_wrapper(proc)
click to toggle source
# File lib/table_sortable/column/filter.rb, line 23 def proc_wrapper(proc) -> (value, col=nil) { instance_exec(value, &proc) } end
run(records)
click to toggle source
# File lib/table_sortable/column/filter.rb, line 27 def run(records) records.instance_exec(query, column, &proc) end
used?()
click to toggle source
# File lib/table_sortable/column/filter.rb, line 31 def used? !query.nil? end