Module: PrawnReportController

Included in:
CustomGenerateReportController
Defined in:
lib/custom_report_controller.rb

Instance Method Summary collapse

Instance Method Details

#get_pr_filtersObject



23
24
25
# File 'lib/custom_report_controller.rb', line 23

def get_pr_filters
  @filters
end

#get_pr_report_classObject



9
10
11
# File 'lib/custom_report_controller.rb', line 9

def get_pr_report_class
  @pr_report_class
end

#get_pr_report_dataObject



5
6
7
# File 'lib/custom_report_controller.rb', line 5

def get_pr_report_data
  []
end

#get_pr_report_paramsObject



15
16
17
# File 'lib/custom_report_controller.rb', line 15

def get_pr_report_params
  @pr_report_params || {}
end

#get_pr_serialization_paramsObject



19
20
21
# File 'lib/custom_report_controller.rb', line 19

def get_pr_serialization_params
  @serialization_params || {}
end

#get_pr_suggested_filenameObject



13
# File 'lib/custom_report_controller.rb', line 13

def get_pr_suggested_filename; end

#indexObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/custom_report_controller.rb', line 27

def index
  @filters = []
  rec = get_pr_report_data
  if rec.nil? || (rec.is_a?(Array) && rec.count == 0)
    render :nothing => true, :status => :no_content
  else
    report_content = rec.pr_serialize(get_pr_serialization_params)
    report = get_pr_report_class.new(get_pr_report_params)
    report.report_params[:filters] = get_pr_filters
    report_content = report.draw(report_content.get_yaml)

    fn = get_pr_suggested_filename

    if fn
      send_data(report_content, :filename => fn)
    else
      send_data(report_content, :disposition => 'inline', :type => 'application/pdf')
    end
  end
end