Sha256: 943edeaac7b52b3759abf2a373ff247d68ba342b6aa646857117a95f04dc8ede
Contents?: true
Size: 1.64 KB
Versions: 4
Compression:
Stored size: 1.64 KB
Contents
module TableSortable class Column attr_reader :name, :label, :filter, :sorter, :template, :placeholder, :content, :translation_key, :options, :template_path def initialize(col_name, *options) options = options.extract_options! value = options[:value] || col_name content = options[:content] || value translation_key = options[:translation_key] template_path = options[:template_path] label = options[:label] || (options[:label] == false ? '' : I18n.translate("table_sortable.#{"#{translation_key}." if translation_key }#{col_name.to_s}", :default => col_name.to_s).titleize) placeholder = options[:placeholder] || (options[:placeholder] == false ? nil : label) # priority = options[:priority] template = options[:template] || col_name column_options = options[:options] || {} # filter_defaultAttrib (data-value) # data-sorter (=false?) @name = col_name @value = value.respond_to?(:call) ? value : -> (record) { record.send(value) } @content = content.respond_to?(:call) ? content : -> (record) { record.send(content) } @label = label @placeholder = placeholder # @sort_priority = sort_priority @template = template @template_path = template_path @options = column_options @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 def content(record) record.instance_eval(&@content) unless @content.nil? end end end
Version data entries
4 entries across 4 versions & 1 rubygems