Class: TableSortable::Column
- Inherits:
-
Object
- Object
- TableSortable::Column
- Defined in:
- lib/table_sortable/column.rb,
lib/table_sortable/column/filter.rb,
lib/table_sortable/column/sorter.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#content(record) ⇒ Object
readonly
Returns the value of attribute content.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#placeholder ⇒ Object
readonly
Returns the value of attribute placeholder.
-
#sorter ⇒ Object
readonly
Returns the value of attribute sorter.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
-
#template_path ⇒ Object
readonly
Returns the value of attribute template_path.
-
#translation_key ⇒ Object
readonly
Returns the value of attribute translation_key.
Instance Method Summary collapse
-
#initialize(col_name, *options) ⇒ Column
constructor
A new instance of Column.
- #value(record) ⇒ Object
Constructor Details
#initialize(col_name, *options) ⇒ Column
Returns a new instance of Column.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/table_sortable/column.rb', line 6 def initialize(col_name, *) = . value = [:value] || col_name content = [:content] || value translation_key = [:translation_key] template_path = [:template_path] label = [:label] || ([:label] == false ? '' : I18n.translate("table_sortable.#{"#{translation_key}." if translation_key }#{col_name.to_s}", :default => col_name.to_s).titleize) placeholder = [:placeholder] || ([:placeholder] == false ? nil : label) # priority = options[:priority] template = [:template] || col_name = [: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 = @filter = TableSortable::Column::Filter.new(.merge(:column => self) ) @sorter = TableSortable::Column::Sorter.new(.merge(:column => self) ) end |
Instance Attribute Details
#content(record) ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/table_sortable/column.rb', line 4 def content @content end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
4 5 6 |
# File 'lib/table_sortable/column.rb', line 4 def filter @filter end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
4 5 6 |
# File 'lib/table_sortable/column.rb', line 4 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/table_sortable/column.rb', line 4 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/table_sortable/column.rb', line 4 def end |
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
4 5 6 |
# File 'lib/table_sortable/column.rb', line 4 def placeholder @placeholder end |
#sorter ⇒ Object (readonly)
Returns the value of attribute sorter.
4 5 6 |
# File 'lib/table_sortable/column.rb', line 4 def sorter @sorter end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
4 5 6 |
# File 'lib/table_sortable/column.rb', line 4 def template @template end |
#template_path ⇒ Object (readonly)
Returns the value of attribute template_path.
4 5 6 |
# File 'lib/table_sortable/column.rb', line 4 def template_path @template_path end |
#translation_key ⇒ Object (readonly)
Returns the value of attribute translation_key.
4 5 6 |
# File 'lib/table_sortable/column.rb', line 4 def translation_key @translation_key end |
Instance Method Details
#value(record) ⇒ Object
36 37 38 |
# File 'lib/table_sortable/column.rb', line 36 def value(record) record.instance_eval(&@value) unless @value.nil? end |