Module: Bowline::Desktop::Bridge::ClassMethods
- Included in:
- Binders::Base, WindowManager, Helpers
- Defined in:
- lib/bowline/desktop/bridge.rb
Instance Method Summary collapse
-
#js_expose(opts = {}) ⇒ Object
Extend you own classes with this module, and then call js_expose to expose your classes’ class variables to JavaScript.
Instance Method Details
#js_expose(opts = {}) ⇒ Object
Extend you own classes with this module, and then call js_expose to expose your classes’ class variables to JavaScript.
Example:
class FooClass
extend Bowline::Desktop::Bridge::ClassMethods
js_expose
def self.foo
return :bar
end
end
JavaScript Example:
Bowline.invoke("FooClass", "foo", function(res){
console.log(res);
})
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bowline/desktop/bridge.rb', line 25 def js_expose(opts = {}) # TODO - implement options, # like :except and :only instance_eval <<-RUBY def js_exposed?(meth) true end def js_invoke(window, callback, method, *args) callback.call(send(method, *args)) end RUBY end |