Skip to content
sergeych edited this page Jan 20, 2015 · 1 revision

is done very much like passing ruby class instances:

class MyClass
   def initialise value
     @value = value
   end

   def foo
     "bar"
   end
end

cxt['Foo'] = MyClass
cxt.eval 'new Foo(1).foo'               # => 'bar'
cxt.eval 'new Foo(2) instanceof Foo'    # => true
cxt.eval 'new Foo(3) instance RubyGate' # => true

Note that all of your gated classes take the name you used when adding it to the workspace, not the original Ruby class name.

All gated ruby classes becomes constructors that call ruby constructors and inherit RubyGate prototype. This let you easily determine all gated instances no matter how they are obtained in JS VM.

Clone this wiki locally