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
10
11
# File 'lib/wisepdf/render.rb', line 5

def self.included(base)
  base.class_eval do
    alias_method_chain :render, :wisepdf
    alias_method_chain :render_to_string, :wisepdf
    after_filter :clean_temp_files
  end
end

Instance Method Details

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



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

def render_to_string_with_wisepdf(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
    render_to_string_without_wisepdf(options, *args, &block)
  end
end

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



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

def render_with_wisepdf(options = nil, *args, &block)
  if options.is_a?(Hash) && options.has_key?(:pdf)
    options = self.default_pdf_render_options.merge(options)
    render_without_wisepdf(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
    render_without_wisepdf(options, *args, &block)
  end
end