module Rhino::Ruby::FunctionCall
@private
Public Instance Methods
call(*args)
click to toggle source
make JavaScript functions callable Ruby
style e.g. `fn.call('42')`
NOTE: That invoking call
does not have the same semantics as JavaScript's Function#call
but rather as Ruby's Method#call ! Use apply or bind before calling to achieve the same effect.
# File lib/rhino/rhino_ext.rb, line 195 def call(*args) with_context do |context| begin # calling as a (var) stored function - no this === undefined "use strict" # TODO can't pass Undefined.instance as this - it's not a Scriptable !? this = Rhino::JS::ScriptRuntime.getGlobal(context) js_args = Rhino.args_to_javascript(args, scope = current_scope(context)) Rhino.to_ruby __call__(context, scope, this, js_args) rescue Rhino::JS::JavaScriptException => e raise Rhino::JSError.new(e) end end end