Module: Princely::PdfHelper

Defined in:
lib/princely/pdf_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


6
7
8
9
# File 'lib/princely/pdf_helper.rb', line 6

def self.included(base)
  base.send :alias_method, :render_without_princely, :render
  base.send :alias_method, :render, :render_with_princely
end

.prepended(base) ⇒ Object


11
12
13
14
# File 'lib/princely/pdf_helper.rb', line 11

def self.prepended(base)
  base.send :alias_method, :render_without_princely, :render
  base.send :alias_method, :render, :render_with_princely
end

Instance Method Details

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


16
17
18
19
20
21
22
23
# File 'lib/princely/pdf_helper.rb', line 16

def render_with_princely(options = nil, *args, &block)
  if options.is_a?(Hash) && options.has_key?(:pdf)
    options[:name] ||= options.delete(:pdf)
    make_and_send_pdf(options.delete(:name), options)
  else
    render_without_princely(options, *args, &block)
  end
end