Module: Wisepdf::Render

Defined in:
lib/wisepdf/render.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
# File 'lib/wisepdf/render.rb', line 5

def self.included(base)
  base.class_eval do
    after_filter :clean_temp_files
  end
end

Instance Method Details

#render(options = nil, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/wisepdf/render.rb', line 11

def render(options = nil, *args, &block)
  if options.is_a?(Hash) && options.has_key?(:pdf)
    options = self.default_pdf_render_options.merge(options)
    super(options.merge(:content_type => "text/html"), *args, &block) and return if options[:show_as_html]

    self.log_pdf_creation
    self.make_and_send_pdf(options)
  else
    super
  end
end

#render_to_string(options = nil, *args, &block) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/wisepdf/render.rb', line 23

def render_to_string(options = nil, *args, &block)
  if options.is_a?(Hash) && options.has_key?(:pdf)
    self.log_pdf_creation
    self.make_pdf(self.default_pdf_render_options.merge(options))
  else
    super
  end
end