Class: Thinreports::SectionReport::Builder::StackViewBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/thinreports/section_report/builder/stack_view_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ StackViewBuilder

Returns a new instance of StackViewBuilder.



9
10
11
# File 'lib/thinreports/section_report/builder/stack_view_builder.rb', line 9

def initialize(item)
  @item = item
end

Instance Method Details

#update(params) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/thinreports/section_report/builder/stack_view_builder.rb', line 13

def update(params)
  rows_params = params[:rows] || {}
  rows_schema = item.internal.format.rows

  rows = []
  rows_schema.each do |row_schema|
    row_params = rows_params[row_schema.id.to_sym] || {}
    next unless row_enabled?(row_schema, row_params)

    items = build_row_items(
      row_schema,
      row_params[:items] || {}
    )

    rows << StackViewData::Row.new(row_schema, items, row_params[:min_height])
  end
  item.internal.rows = rows
end