Class: MagicReport::Report::Builder::HasMany

Inherits:
HasOne
  • Object
show all
Defined in:
lib/magic_report/report/builder/has_many.rb

Instance Attribute Summary

Attributes inherited from HasOne

#extension, #name, #options, #prefix, #report

Instance Method Summary collapse

Methods inherited from HasOne

build, #build_row, #initialize, #process

Constructor Details

This class inherits a constructor from MagicReport::Report::Builder::HasOne

Instance Method Details

#process_rows(model, row) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/magic_report/report/builder/has_many.rb', line 7

def process_rows(model, row)
  extract_relation(model).map.with_index do |rel, idx|
    # If we're on a first entry, then we should fill first row
    # Otherwise will be created a new row
    if idx.zero?
      options[:class].new(rel, row).rows
    else
      options[:class].new(rel).rows
    end
  end
end