Sha256: 5ef6700e6777e55a05857f02a543d57c2dc9d5751b415d54c3cd79277a965cba
Contents?: true
Size: 717 Bytes
Versions: 1
Compression:
Stored size: 717 Bytes
Contents
module TableSortable class Column class Filter include TableSortable::Concerns::Proc attr_accessor :query def initialize(*args) super :filter, *args end def array_proc -> (value, col=nil) { select{|record| value.downcase.in? col.value(record).to_s.downcase} } end def sql_proc -> (value, col=nil) { where("LOWER(?) LIKE (?)", filter.to_s.underscore, "%#{value.to_s.downcase}%") } end def proc_wrapper(proc) -> (value, col=nil) { instance_exec(value, &proc) } end def run(records) records.instance_exec(query, column, &proc) end def used? !query.nil? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
table_sortable-0.2.0 | lib/table_sortable/column/filter.rb |