Class: CsvRowModel::Import::DynamicColumnAttribute

Inherits:
DynamicColumnAttributeBase show all
Defined in:
lib/csv_row_model/internal/import/dynamic_column_attribute.rb

Instance Attribute Summary collapse

Attributes inherited from AttributeBase

#column_name, #row_model

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DynamicColumnAttributeBase

#call_process_cell, #formatted_cells, process_cell_method_name, #process_cell_method_name, #value

Methods included from DynamicColumnShared

#column_index, #header_models, #header_models_context_key, #options

Methods included from ColumnShared

#context, #options

Methods inherited from AttributeBase

#formatted_value, #row_model_class

Constructor Details

#initialize(column_name, source_headers, source_cells, row_model) ⇒ DynamicColumnAttribute

Returns a new instance of DynamicColumnAttribute


8
9
10
11
12
# File 'lib/csv_row_model/internal/import/dynamic_column_attribute.rb', line 8

def initialize(column_name, source_headers, source_cells, row_model)
  @source_headers = source_headers
  @source_cells = source_cells
  super(column_name, row_model)
end

Instance Attribute Details

#source_cellsObject (readonly)

Returns the value of attribute source_cells


6
7
8
# File 'lib/csv_row_model/internal/import/dynamic_column_attribute.rb', line 6

def source_cells
  @source_cells
end

#source_headersObject (readonly)

Returns the value of attribute source_headers


6
7
8
# File 'lib/csv_row_model/internal/import/dynamic_column_attribute.rb', line 6

def source_headers
  @source_headers
end

Class Method Details

.define_process_cell(row_model_class, column_name) ⇒ Object


27
28
29
# File 'lib/csv_row_model/internal/import/dynamic_column_attribute.rb', line 27

def define_process_cell(row_model_class, column_name)
  super { |formatted_cell, source_headers| formatted_cell }
end

Instance Method Details

#formatted_headersObject


20
21
22
23
24
# File 'lib/csv_row_model/internal/import/dynamic_column_attribute.rb', line 20

def formatted_headers
  source_headers.map do |source_headers|
    row_model_class.format_dynamic_column_header(source_headers, column_name, row_model.context)
  end
end

#unformatted_valueObject


14
15
16
17
18
# File 'lib/csv_row_model/internal/import/dynamic_column_attribute.rb', line 14

def unformatted_value
  formatted_cells.zip(formatted_headers).map do |formatted_cell, source_headers|
    call_process_cell(formatted_cell, source_headers)
  end
end