Module: Csvbuilder::Export::Base

Extended by:
ActiveSupport::Concern
Included in:
Csvbuilder::Export
Defined in:
lib/csvbuilder/exporter/concerns/export/base.rb

Instance Method Summary collapse

Instance Method Details

#initialize(source_model = nil, context = {}) ⇒ Object

Parameters:

  • source_model (Model) (defaults to: nil)

    object to export to CSV

  • context (Hash) (defaults to: {})


15
16
17
18
# File 'lib/csvbuilder/exporter/concerns/export/base.rb', line 15

def initialize(source_model = nil, context = {})
  @source_model = source_model
  super(context: context)
end

#to_rowArray

Returns an array of public_send(column_name) of the CSV model.

Returns:

  • (Array)

    an array of public_send(column_name) of the CSV model



25
26
27
# File 'lib/csvbuilder/exporter/concerns/export/base.rb', line 25

def to_row
  original_attributes.values
end

#to_rowsObject



20
21
22
# File 'lib/csvbuilder/exporter/concerns/export/base.rb', line 20

def to_rows
  [to_row]
end