Class: EacRailsUtils::DataTableHelper::Column
- Inherits:
-
Object
- Object
- EacRailsUtils::DataTableHelper::Column
- Defined in:
- app/helpers/eac_rails_utils/data_table_helper/column.rb
Constant Summary collapse
- EMPTY_VALUE =
'-'
Instance Method Summary collapse
- #label ⇒ String
- #path ⇒ String
- #record_value(record) ⇒ Object
- #value_cell(attribute, value = nil, &block) ⇒ self
- #value_cell_attributes ⇒ Hash
Instance Method Details
#label ⇒ String
11 12 13 |
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 11 def label args[0] end |
#path ⇒ String
16 17 18 |
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 16 def path args[1].to_s.split('.') end |
#record_value(record) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 20 def record_value(record) v = ::EacRailsUtils::DataTableHelper::ColumnNode.new(record, path).value if v.present? block ? block.call(v) : v else EMPTY_VALUE end end |
#value_cell(attribute, value = nil, &block) ⇒ self
32 33 34 35 36 |
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 32 def value_cell(attribute, value = nil, &block) value_cell_attributes[attribute.to_sym] = block.if_present(value) self end |
#value_cell_attributes ⇒ Hash
39 40 41 |
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 39 def value_cell_attributes @value_cell_attributes ||= {} end |