Class: Bidi2pdfRails::Services::RenderOptionsHandler
- Inherits:
-
Object
- Object
- Bidi2pdfRails::Services::RenderOptionsHandler
- Defined in:
- lib/bidi2pdf_rails/services/render_options_handler.rb
Constant Summary collapse
- PDF_OPTIONS =
PdfRenderer::PDF_OPTIONS
- PRINT_URL_OPTIONS =
PdfRenderer::PRINT_URL_OPTIONS
Instance Attribute Summary collapse
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#pdf ⇒ Object
readonly
Returns the value of attribute pdf.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(filename, options, controller, bidi2pdf_rails_config: Bidi2pdfRails.config) ⇒ RenderOptionsHandler
constructor
A new instance of RenderOptionsHandler.
- #inline_rendering_needed? ⇒ Boolean
- #job_options ⇒ Object
-
#render_inline! ⇒ Object
Call this method to render the HTML inline, within the controller, in cases where you want to render within the current controller context.
Constructor Details
#initialize(filename, options, controller, bidi2pdf_rails_config: Bidi2pdfRails.config) ⇒ RenderOptionsHandler
Returns a new instance of RenderOptionsHandler.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bidi2pdf_rails/services/render_options_handler.rb', line 15 def initialize(filename, , controller, bidi2pdf_rails_config: Bidi2pdfRails.config) @original_options = .deep_dup # Store original options pdf_opts = .slice(*PDF_OPTIONS) print_url_opts = .slice(*PRINT_URL_OPTIONS) html_opts = .except(*PDF_OPTIONS + PRINT_URL_OPTIONS) @pdf = PdfOptions.new(filename, pdf_opts, controller, bidi2pdf_rails_config:) @url = PrintUrlOptions.new(print_url_opts, controller, bidi2pdf_rails_config:) @html = HtmlOptions.new(html_opts, @pdf, controller) end |
Instance Attribute Details
#html ⇒ Object (readonly)
Returns the value of attribute html.
13 14 15 |
# File 'lib/bidi2pdf_rails/services/render_options_handler.rb', line 13 def html @html end |
#pdf ⇒ Object (readonly)
Returns the value of attribute pdf.
13 14 15 |
# File 'lib/bidi2pdf_rails/services/render_options_handler.rb', line 13 def pdf @pdf end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
13 14 15 |
# File 'lib/bidi2pdf_rails/services/render_options_handler.rb', line 13 def url @url end |
Instance Method Details
#inline_rendering_needed? ⇒ Boolean
27 28 29 |
# File 'lib/bidi2pdf_rails/services/render_options_handler.rb', line 27 def inline_rendering_needed? !(@url.url? || @original_options[:inline]) end |
#job_options ⇒ Object
39 40 41 |
# File 'lib/bidi2pdf_rails/services/render_options_handler.rb', line 39 def @original_options end |
#render_inline! ⇒ Object
Call this method to render the HTML inline, within the controller, in cases where you want to render within the current controller context.
33 34 35 36 37 |
# File 'lib/bidi2pdf_rails/services/render_options_handler.rb', line 33 def render_inline! return unless inline_rendering_needed? @original_options[:inline] = html.html end |