Module: NodeModule
- Defined in:
- lib/node_module.rb,
lib/node_module/version.rb,
lib/node_module/compiled.rb
Defined Under Namespace
Modules: ClassMethods
Classes: Compiled, OpalJsContext
Constant Summary
collapse
- VERSION =
"0.2.1"
Class Method Summary
collapse
Class Method Details
.compile_and_replace!(receiver, methods) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/node_module.rb', line 29
def self.compile_and_replace!(receiver, methods)
methods.each do |name|
meth = receiver.instance_method(name).to_ruby
self.opal_js_context.compile(meth)
self.replace_method!(receiver, name)
end
end
|
.compile_on_callback(receiver) ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/node_module.rb', line 37
def self.compile_on_callback(receiver)
active = nil
receiver.define_singleton_method(:method_added) do |name|
return if active
active = true
receiver.node_module(name)
active = false
end
end
|
.included(receiver) ⇒ Object
11
12
13
|
# File 'lib/node_module.rb', line 11
def self.included(receiver)
receiver.extend ClassMethods
end
|
.opal_js_context ⇒ Object
15
16
17
|
# File 'lib/node_module.rb', line 15
def self.opal_js_context
@ctx ||= OpalJsContext.new
end
|
.replace_method!(receiver, name) ⇒ Object
47
48
49
50
51
|
# File 'lib/node_module.rb', line 47
def self.replace_method!(receiver, name)
receiver.send :define_method, name do |*args|
NodeModule.opal_js_context.run(__method__, args)
end
end
|