class ReactiveRuby::ServerRendering::ContextualRenderer

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method
# File lib/reactive-ruby/server_rendering/contextual_renderer.rb, line 13
def initialize(options = {})
  super(options)
  ComponentLoader.new(v8_context).load
end

Public Instance Methods

render(component_name, props, prerender_options) click to toggle source
Calls superclass method
# File lib/reactive-ruby/server_rendering/contextual_renderer.rb, line 18
def render(component_name, props, prerender_options)
  if prerender_options.is_a?(Hash)
    if v8_runtime? && prerender_options[:context_initializer]
      raise PrerenderError.new(component_name, props, "you must use 'therubyracer' with the prerender[:context] option") unless v8_runtime?
    else
      prerender_options[:context_initializer].call v8_context
      prerender_options = prerender_options[:static] ? :static : true
    end
  end

  super(component_name, props, prerender_options)
end

Private Instance Methods

v8_context() click to toggle source
# File lib/reactive-ruby/server_rendering/contextual_renderer.rb, line 37
def v8_context
  @v8_context ||= ReactiveRuby::ServerRendering.context_instance_for(@context)
end
v8_runtime?() click to toggle source
# File lib/reactive-ruby/server_rendering/contextual_renderer.rb, line 33
def v8_runtime?
  ["(V8)", "therubyrhino (Rhino)"].include?(ExecJS.runtime.name)
end