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
13 14 15 |
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 13 def label args[0] end |
#path ⇒ String
18 19 20 |
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 18 def path args[1].to_s.split('.') end |
#record_value(record) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 22 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
34 35 36 37 38 |
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 34 def value_cell(attribute, value = nil, &block) value_cell_attributes[attribute.to_sym] = block.if_present(value) self end |
#value_cell_attributes ⇒ Hash
41 42 43 |
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 41 def value_cell_attributes @value_cell_attributes ||= {} end |