module PrawnReportController

Public Instance Methods

get_pr_filters() click to toggle source
# File lib/custom_report_controller.rb, line 23
def get_pr_filters
  @filters
end
get_pr_report_class() click to toggle source
# File lib/custom_report_controller.rb, line 9
def get_pr_report_class
  @pr_report_class
end
get_pr_report_data() click to toggle source
# File lib/custom_report_controller.rb, line 5
def get_pr_report_data
  []
end
get_pr_report_params() click to toggle source
# File lib/custom_report_controller.rb, line 15
def get_pr_report_params
  @pr_report_params || {}
end
get_pr_serialization_params() click to toggle source
# File lib/custom_report_controller.rb, line 19
def get_pr_serialization_params
  @serialization_params || {}
end
get_pr_suggested_filename() click to toggle source
# File lib/custom_report_controller.rb, line 13
def get_pr_suggested_filename; end
index() click to toggle source
# 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