Module: ReportsKit::Helper

Defined in:
lib/reports_kit/helper.rb

Instance Method Summary collapse

Instance Method Details

#context_paramsObject



22
23
24
# File 'lib/reports_kit/helper.rb', line 22

def context_params
  params[:context_params]
end

#render_report(report_params, context_params: {}, actions: %w(export_csv export_xls),, js_report_class: 'Report', &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/reports_kit/helper.rb', line 3

def render_report(report_params, context_params: {}, actions: %w(export_csv export_xls), js_report_class: 'Report', &block)
  report_params = { key: report_params } if report_params.is_a?(String)
  params.merge!(context_params: context_params, report_params: report_params)
  properties = instance_eval(&ReportsKit.configuration.properties_method).deep_symbolize_keys
  builder = ReportBuilder.new(
    report_params: report_params,
    context_params: context_params,
    actions: actions,
    js_report_class: js_report_class,
    properties: properties,
    view_context: self,
    block: block
  )
  capture do
    capture(builder, &block) if block
    builder.render
  end
end

#report_keyObject



30
31
32
# File 'lib/reports_kit/helper.rb', line 30

def report_key
  report_params[:key]
end

#report_paramsObject



26
27
28
# File 'lib/reports_kit/helper.rb', line 26

def report_params
  params[:report_params]
end