module CsvRowModel::Export::Base
Attributes
context[R]
source_model[R]
Public Class Methods
new(source_model, context={})
click to toggle source
@param [Model] source_model
object to export to CSV @param [Hash] context
# File lib/csv_row_model/export/base.rb, line 13 def initialize(source_model, context={}) @source_model = source_model @context = OpenStruct.new(context) end
Public Instance Methods
setup(csv, context={}, with_headers: true)
click to toggle source
# File lib/csv_row_model/export/base.rb, line 28 def setup(csv, context={}, with_headers: true) csv << headers(context) if with_headers end
to_row()
click to toggle source
@return [Array] an array of public_send(column_name) of the CSV model
# File lib/csv_row_model/export/base.rb, line 23 def to_row formatted_attributes.values end
to_rows()
click to toggle source
# File lib/csv_row_model/export/base.rb, line 18 def to_rows [to_row] end