Sha256: 553037bf6fb2c52c2206c689734757368b41663a60b6806ab7cc548f3dc48a50
Contents?: true
Size: 921 Bytes
Versions: 1
Compression:
Stored size: 921 Bytes
Contents
module TableSortable class Column attr_reader :name, :label, :filter, :sorter, :template, :placeholder def initialize(col_name, *options) options = options.extract_options! value = options[:value] || col_name label = options[:label] || (options[:label] == false ? '' : col_name.to_s.titleize) placeholder = options[:placeholder] || (options[:placeholder] == false ? false : label) template = options[:template] || col_name @name = col_name @value = value.is_a?(Proc) ? value : -> (record) { record.send(value) } @label = label @placeholder = placeholder @template = template @filter = TableSortable::Column::Filter.new(options.merge(:column => self) ) @sorter = TableSortable::Column::Sorter.new(options.merge(:column => self) ) end def value(record) record.instance_eval(&@value) unless @value.nil? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
table_sortable-0.2.0 | lib/table_sortable/column.rb |