Class: ReportResponse
- Inherits:
 - 
      Object
      
        
- Object
 - ReportResponse
 
 - Defined in:
 - backend/app/lib/reports/report_response.rb
 
Overview
this is a generic wrapper for reports reponses. JasperReports do not need a reponse wrapper and can return reports on formats using the to_FORMAT convention. “Classic” AS reports need a wrapper to render the report in a specific format.
Instance Attribute Summary (collapse)
- 
  
    
      - (Object) base_url 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute base_url.
 - 
  
    
      - (Object) report 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute report.
 
Instance Method Summary (collapse)
- 
  
    
      - (Object) generate 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      - (ReportResponse) initialize(report, params = {}) 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of ReportResponse.
 
Constructor Details
- (ReportResponse) initialize(report, params = {})
Returns a new instance of ReportResponse
      17 18 19 20  | 
    
      # File 'backend/app/lib/reports/report_response.rb', line 17 def initialize(report, params = {} ) @report = report @params = params end  | 
  
Instance Attribute Details
- (Object) base_url
Returns the value of attribute base_url
      15 16 17  | 
    
      # File 'backend/app/lib/reports/report_response.rb', line 15 def base_url @base_url end  | 
  
- (Object) report
Returns the value of attribute report
      14 15 16  | 
    
      # File 'backend/app/lib/reports/report_response.rb', line 14 def report @report end  | 
  
Instance Method Details
- (Object) generate
      22 23 24 25 26 27 28 29 30 31 32 33 34 35  | 
    
      # File 'backend/app/lib/reports/report_response.rb', line 22 def generate if @report.is_a?(JasperReport) format = @report.format String.from_java_bytes( @report.render(format.to_sym, @params) ) else file = File.join( File.dirname(__FILE__), "../../views/reports/report.erb") @params[:html_report] ||= proc { ERB.new( IO.read( file )).result(@report.get_binding) } format = @report.format klass = Object.const_get("#{format.upcase}Response") klass.send(:new, @report, @params).generate end end  |