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
-
#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.
-
#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.
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 |
# File 'lib/table_sortable/column.rb', line 6 def initialize(col_name, *) = . value = [:value] || col_name label = [:label] || ([:label] == false ? '' : col_name.to_s.titleize) placeholder = [:placeholder] || ([:placeholder] == false ? false : label) template = [: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(.merge(:column_name => @name) ) @sorter = TableSortable::Column::Sorter.new(.merge(:column_name => @name) ) end |
Instance Attribute Details
#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 |
#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 |
Instance Method Details
#value(record) ⇒ Object
24 25 26 |
# File 'lib/table_sortable/column.rb', line 24 def value(record) record.instance_eval(&@value) unless @value.nil? end |