Class: Csvbuilder::DynamicColumnAttributeBase
- Inherits:
-
AttributeBase
- Object
- AttributeBase
- Csvbuilder::DynamicColumnAttributeBase
- Includes:
- DynamicColumnShared
- Defined in:
- lib/csvbuilder/dynamic/columns/core/internal/dynamic_column_attribute_base.rb
Class Method Summary collapse
-
.define_process_cell(row_model_class, column_name, &block) ⇒ Object
define a method to process each cell of the attribute method process_cell = one cell attribute_method = many cells = [process_cell(), process_cell()…].
- .process_cell_method_name(column_name) ⇒ Object
Instance Method Summary collapse
-
#formatted_cells ⇒ Array
The source_cells is meant to be implemented in the concret class.
- #source_cells ⇒ Object
- #unformatted_value ⇒ Object
-
#value ⇒ Array
The value is the collection of cell’s values.
Methods included from DynamicColumnShared
#column_index, #header_models, #header_models_context_key, #options
Class Method Details
.define_process_cell(row_model_class, column_name, &block) ⇒ Object
define a method to process each cell of the attribute method process_cell = one cell attribute_method = many cells = [process_cell(), process_cell()…]
51 52 53 |
# File 'lib/csvbuilder/dynamic/columns/core/internal/dynamic_column_attribute_base.rb', line 51 def define_process_cell(row_model_class, column_name, &block) row_model_class.define_proxy_method(process_cell_method_name(column_name), &block) end |
.process_cell_method_name(column_name) ⇒ Object
44 45 46 |
# File 'lib/csvbuilder/dynamic/columns/core/internal/dynamic_column_attribute_base.rb', line 44 def process_cell_method_name(column_name) column_name.to_s.singularize.to_sym end |
Instance Method Details
#formatted_cells ⇒ Array
The source_cells is meant to be implemented in the concret class
18 19 20 21 22 |
# File 'lib/csvbuilder/dynamic/columns/core/internal/dynamic_column_attribute_base.rb', line 18 def formatted_cells source_cells.map do |cell| row_model_class.format_cell(cell, column_name, row_model.context) end end |
#source_cells ⇒ Object
24 25 26 |
# File 'lib/csvbuilder/dynamic/columns/core/internal/dynamic_column_attribute_base.rb', line 24 def source_cells raise NotImplementedError end |
#unformatted_value ⇒ Object
28 29 30 |
# File 'lib/csvbuilder/dynamic/columns/core/internal/dynamic_column_attribute_base.rb', line 28 def unformatted_value raise NotImplementedError end |
#value ⇒ Array
The value is the collection of cell’s values
12 13 14 |
# File 'lib/csvbuilder/dynamic/columns/core/internal/dynamic_column_attribute_base.rb', line 12 def value @value ||= row_model_class.format_dynamic_column_cells(unformatted_value, column_name, row_model.context) end |