Skip to content

passing ruby callables

sergeych edited this page Dec 27, 2014 · 1 revision

Is the same as passing any ruby object:

cxt = H8::Context.new
cxt[:foo] = -> (a,b) {
  a+b
}
res = cxt.eval 'foo(100, 11)' # => 111

The ruby lambda (or Proc, whatever) will turn into javascript function that js code can use in any way. Possible arguments will be gated to ruby objects as need, the same as returned value will be gated to javascript. See object conversion.

Clone this wiki locally