class ReactiveRuby::ComponentLoader

Attributes

v8_context[R]

Public Class Methods

new(v8_context) click to toggle source
# File lib/reactive-ruby/component_loader.rb, line 6
def initialize(v8_context)
  unless v8_context
    raise ArgumentError.new('Could not obtain ExecJS runtime context')
  end
  @v8_context = v8_context
end

Public Instance Methods

load(file = components) click to toggle source
# File lib/reactive-ruby/component_loader.rb, line 13
def load(file = components)
  return true if loaded?
  !!v8_context.eval(opal(file))
end
load!(file = components) click to toggle source
# File lib/reactive-ruby/component_loader.rb, line 18
def load!(file = components)
  return true if loaded?
  self.load(file)
ensure
  raise "No react.rb components found in #{components}.rb" unless loaded?
end
loaded?() click to toggle source
# File lib/reactive-ruby/component_loader.rb, line 25
def loaded?
  !!v8_context.eval('Opal.React')
end

Private Instance Methods

assets() click to toggle source
# File lib/reactive-ruby/component_loader.rb, line 45
def assets
  ::Rails.application.assets
end
components() click to toggle source
# File lib/reactive-ruby/component_loader.rb, line 31
def components
  # Make this configurable at some point
  'components'
end
opal(file) click to toggle source
# File lib/reactive-ruby/component_loader.rb, line 36
def opal(file)
  if Opal::Processor.respond_to?(:load_asset_code)
    Opal::Processor.load_asset_code(assets, file)
  else
    Opal::Sprockets.load_asset(file, assets)
  end
rescue # What exception is being caught here?
end