Class: PDFGen::DsActiveRecord

Inherits:
DsBase
  • Object
show all
Defined in:
lib/data/ds_ar.rb

Instance Method Summary collapse

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

#bodyObject



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

#columnsObject



10
11
12
# File 'lib/data/ds_ar.rb', line 10

def columns
  @data.first.class.columns.map(&:name)
end

#eachObject



26
27
28
# File 'lib/data/ds_ar.rb', line 26

def each
  self.body.each {|item| yield item}
end