Module: WickedPdf::PdfHelper
- Defined in:
- lib/wicked_pdf/pdf_helper.rb
Class Method Summary collapse
Instance Method Summary collapse
- #render_to_string_with_wicked_pdf(options = nil, *args, &block) ⇒ Object
- #render_with_wicked_pdf(options = nil, *args, &block) ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/wicked_pdf/pdf_helper.rb', line 3 def self.included(base) # Protect from trying to augment modules that appear # as the result of adding other gems. return if base != ActionController::Base base.class_eval do alias_method_chain :render, :wicked_pdf alias_method_chain :render_to_string, :wicked_pdf after_filter :clean_temp_files end end |
.prepended(base) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wicked_pdf/pdf_helper.rb', line 15 def self.prepended(base) # Protect from trying to augment modules that appear # as the result of adding other gems. return if base != ActionController::Base base.class_eval do after_action :clean_temp_files alias_method :render_without_wicked_pdf, :render alias_method :render_to_string_without_wicked_pdf, :render_to_string def render( = nil, *args, &block) render_with_wicked_pdf(, *args, &block) end def render_to_string( = nil, *args, &block) render_to_string_with_wicked_pdf(, *args, &block) end end end |
Instance Method Details
#render_to_string_with_wicked_pdf(options = nil, *args, &block) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/wicked_pdf/pdf_helper.rb', line 46 def render_to_string_with_wicked_pdf( = nil, *args, &block) if .is_a?(Hash) && .key?(:pdf) log_pdf_creation [:basic_auth] = set_basic_auth() .delete :pdf make_pdf((WickedPdf.config || {}).merge()) else render_to_string_without_wicked_pdf(, *args, &block) end end |
#render_with_wicked_pdf(options = nil, *args, &block) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/wicked_pdf/pdf_helper.rb', line 36 def render_with_wicked_pdf( = nil, *args, &block) if .is_a?(Hash) && .key?(:pdf) log_pdf_creation [:basic_auth] = set_basic_auth() make_and_send_pdf(.delete(:pdf), (WickedPdf.config || {}).merge()) else render_without_wicked_pdf(, *args, &block) end end |