Module: Renderer

Defined in:
lib/stripe_invoice/renderer.rb

Class Method Summary collapse

Class Method Details

.render(options = {}) ⇒ Object

Renders a view.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/stripe_invoice/renderer.rb', line 4

def self.render options = {}

  # Pass a hash of local variables as :assigns.
  assigns = options.delete(:assigns) || {}

  # Create a view.
  view = view_class.new ActionController::Base.view_paths, assigns

  # Mix in other helpers you need.
  view.extend ApplicationHelper
  view.extend StripeInvoice::ApplicationHelper
  view.extend StripeInvoice::TaxReportHelper

  # Render.
  view.render options
end

.view_classObject

Creates a subclass of ActionView::Base with route helpers mixed in.



22
23
24
25
26
# File 'lib/stripe_invoice/renderer.rb', line 22

def self.view_class
  @view_class ||= Class.new ActionView::Base do
    include Rails.application.routes.url_helpers
  end
end