Module: Csvbuilder::DynamicColumnShared

Extended by:
ActiveSupport::Concern
Includes:
ColumnShared
Included in:
DynamicColumnAttributeBase, Model::DynamicColumnHeader
Defined in:
lib/csvbuilder/dynamic/columns/core/internal/concerns/dynamic_column_shared.rb

Instance Method Summary collapse

Instance Method Details

#column_indexObject

row_model_class



13
14
15
# File 'lib/csvbuilder/dynamic/columns/core/internal/concerns/dynamic_column_shared.rb', line 13

def column_index
  @column_index ||= row_model_class.dynamic_column_index(column_name)
end

#header_modelsArray

header models

return the collection given by the context i.e: skills: [“Ruby”, “Python”, “Javascript”] header_models => [“Ruby”, “Python”, “Javascript”]

Returns:

  • (Array)

    Array of values



29
30
31
# File 'lib/csvbuilder/dynamic/columns/core/internal/concerns/dynamic_column_shared.rb', line 29

def header_models
  Array(context.public_send(header_models_context_key))
end

#header_models_context_keySymbol

The name of the dynamic_column

i.e: With dynamic_column :skills

> :skills

i.e: With dynamic_column :skills, as: :programming_languages

> :programming_languages

Returns:

  • (Symbol)

    Symbol



42
43
44
# File 'lib/csvbuilder/dynamic/columns/core/internal/concerns/dynamic_column_shared.rb', line 42

def header_models_context_key
  options[:as] || column_name
end

#optionsObject



17
18
19
# File 'lib/csvbuilder/dynamic/columns/core/internal/concerns/dynamic_column_shared.rb', line 17

def options
  row_model_class.dynamic_columns[column_name]
end