Class: ReactiveRuby::ComponentLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/reactive-ruby/component_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(v8_context) ⇒ ComponentLoader

Returns a new instance of ComponentLoader.



6
7
8
# File 'lib/reactive-ruby/component_loader.rb', line 6

def initialize(v8_context)
  @v8_context = v8_context
end

Instance Method Details

#load(file = components) ⇒ Object



10
11
12
13
# File 'lib/reactive-ruby/component_loader.rb', line 10

def load(file = components)
  return true if loaded?
  !!v8_context.eval(opal(file))
end

#load!(file = components) ⇒ Object



15
16
17
18
19
20
# File 'lib/reactive-ruby/component_loader.rb', line 15

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?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/reactive-ruby/component_loader.rb', line 22

def loaded?
  !!v8_context.eval('Opal.React')
end