Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoiding empty if statement and removing some whitespace. #27

Closed
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -1,33 +1,32 @@
# -*- encoding: utf-8 -*-
module JasperRails

class AbstractRenderer

class_attribute :after_fill_blocks
self.after_fill_blocks = []

def self.register(file_extension, options = {}, &block)
renderer = self.new(file_extension, options, &block)

if Mime::Type.lookup_by_extension(file_extension).nil?
Mime::Type.register options[:mime_type], file_extension.to_sym
end

ActionController::Responder.send(:define_method, "to_#{file_extension}") do
if template_name = self.options[:template]
else
template_name = "#{controller.controller_path}/#{controller.action_name}"
end
template_name = self.options[:template]
template_name ||= "#{controller.controller_path}/#{controller.action_name}"

details_options = {:formats => [:jrxml], :handlers => []}

jrxml_file = controller.lookup_context.find_template(template_name,[],false,[],details_options).identifier
jasper_file = jrxml_file.sub(/\.jrxml$/, ".jasper")
jasper_file = jrxml_file.sub(/\.jrxml$/, ".jasper")

params = {}
controller.instance_variables.each do |v|
params[v.to_s[1..-1]] = controller.instance_variable_get(v)
end

response_options = JasperRails.config[:response_options].merge(:type => options[:mime_type])
controller.send_data renderer.render(jasper_file, resource, params, self.options), response_options
end
ProTip! Use n and p to navigate between commits in a pull request.