Class: MrCommon::DefaultCSVExportAdapter

Inherits:
Object
  • Object
show all
Defined in:
app/models/mr_common/default_csv_export_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exportable) ⇒ DefaultCSVExportAdapter

Returns a new instance of DefaultCSVExportAdapter.



7
8
9
# File 'app/models/mr_common/default_csv_export_adapter.rb', line 7

def initialize(exportable)
  @exportable = exportable
end

Instance Attribute Details

#exportableObject (readonly)

Returns the value of attribute exportable.



5
6
7
# File 'app/models/mr_common/default_csv_export_adapter.rb', line 5

def exportable
  @exportable
end

Instance Method Details

#collectionObject



11
12
13
# File 'app/models/mr_common/default_csv_export_adapter.rb', line 11

def collection
  exportable.all
end

#headersObject



19
20
21
# File 'app/models/mr_common/default_csv_export_adapter.rb', line 19

def headers
  exportable.column_names
end

#row_from_item(item) ⇒ Object



15
16
17
# File 'app/models/mr_common/default_csv_export_adapter.rb', line 15

def row_from_item(item)
  item.attributes.values_at(*headers)
end