Class: ReactiveRuby::ComponentLoader
- Defined in:
- lib/reactive-ruby/component_loader.rb
Instance Method Summary collapse
-
#initialize(v8_context) ⇒ ComponentLoader
constructor
A new instance of ComponentLoader.
- #load(file = components) ⇒ Object
- #load!(file = components) ⇒ Object
- #loaded? ⇒ Boolean
Constructor Details
#initialize(v8_context) ⇒ ComponentLoader
Returns a new instance of ComponentLoader.
6 7 8 9 10 11 |
# 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 |
Instance Method Details
#load(file = components) ⇒ Object
13 14 15 16 |
# 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) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/reactive-ruby/component_loader.rb', line 18 def load!(file = components) return true if loaded? self.load(file) ensure raise "No HyperReact components found in #{components}" unless loaded? end |
#loaded? ⇒ Boolean
25 26 27 28 29 |
# File 'lib/reactive-ruby/component_loader.rb', line 25 def loaded? !!v8_context.eval('Opal.React !== undefined') rescue ::ExecJS::Error false end |