Class: PDFGen::DsActiveRecord
Instance Method Summary collapse
- #body ⇒ Object
- #columns ⇒ Object
- #each ⇒ Object
-
#initialize(data) ⇒ DsActiveRecord
constructor
A new instance of DsActiveRecord.
Constructor Details
#initialize(data) ⇒ DsActiveRecord
Returns a new instance of DsActiveRecord.
6 7 8 |
# File 'lib/data/ds_ar.rb', line 6 def initialize(data) @data = data end |
Instance Method Details
#body ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/data/ds_ar.rb', line 14 def body @fields = [] @data.each do |row| @mas = [] columns.each do |title| @mas << row.send(title) end @fields << @mas end @fields end |
#columns ⇒ Object
10 11 12 |
# File 'lib/data/ds_ar.rb', line 10 def columns @data.first.class.columns.map(&:name) end |
#each ⇒ Object
26 27 28 |
# File 'lib/data/ds_ar.rb', line 26 def each self.body.each {|item| yield item} end |