Module: CsvRowModel::Export::Base
- Extended by:
- ActiveSupport::Concern
- Included in:
- CsvRowModel::Export
- Defined in:
- lib/csv_row_model/export/base.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#source_model ⇒ Object
readonly
Returns the value of attribute source_model.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(source_model, context = {}) ⇒ Object
-
#to_row ⇒ Array
An array of public_send(column_name) of the CSV model.
- #to_rows ⇒ Object
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'lib/csv_row_model/export/base.rb', line 7 def context @context end |
#source_model ⇒ Object (readonly)
Returns the value of attribute source_model.
7 8 9 |
# File 'lib/csv_row_model/export/base.rb', line 7 def source_model @source_model end |
Class Method Details
.setup(csv, context = {}, with_headers: true) ⇒ Object
28 29 30 |
# File 'lib/csv_row_model/export/base.rb', line 28 def setup(csv, context={}, with_headers: true) csv << headers(context) if with_headers end |
Instance Method Details
#initialize(source_model, context = {}) ⇒ Object
13 14 15 16 |
# File 'lib/csv_row_model/export/base.rb', line 13 def initialize(source_model, context={}) @source_model = source_model @context = OpenStruct.new(context) end |
#to_row ⇒ Array
Returns an array of public_send(column_name) of the CSV model.
23 24 25 |
# File 'lib/csv_row_model/export/base.rb', line 23 def to_row formatted_attributes.values end |
#to_rows ⇒ Object
18 19 20 |
# File 'lib/csv_row_model/export/base.rb', line 18 def to_rows [to_row] end |