Class: OldSchool::CSV::ContentRow

Inherits:
Object
  • Object
show all
Defined in:
lib/old_school/csv/content_row.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ ContentRow

Returns a new instance of ContentRow.



8
9
10
11
# File 'lib/old_school/csv/content_row.rb', line 8

def initialize(model)
  @model = model
  @public_attributes = model.publicly_readable_attributes
end

Class Method Details

.for(model) ⇒ Object



4
5
6
# File 'lib/old_school/csv/content_row.rb', line 4

def self.for(model)
  new(model).to_csv
end

Instance Method Details

#to_csvObject



13
14
15
16
17
# File 'lib/old_school/csv/content_row.rb', line 13

def to_csv
  @public_attributes.map{|attribute|
    values_for(attribute)
  }.flatten
end