# File lib/execjs/ruby_rhino_runtime.rb, line 34 def call(properties, *args) unbox @rhino_context.eval(properties).call(*args) rescue ::Rhino::JavascriptError => e if e.message == "syntax error" raise RuntimeError, e.message else raise ProgramError, e.message end end
# File lib/execjs/ruby_rhino_runtime.rb, line 20 def eval(source, options = {}) source = source.encode('UTF-8') if source.respond_to?(:encode) if /\S/ =~ source unbox @rhino_context.eval("(#{source})") end rescue ::Rhino::JavascriptError => e if e.message == "syntax error" raise RuntimeError, e.message else raise ProgramError, e.message end end
# File lib/execjs/ruby_rhino_runtime.rb, line 12 def exec(source, options = {}) source = source.encode('UTF-8') if source.respond_to?(:encode) if /\S/ =~ source eval "(function(){#{source}})()", options end end
# File lib/execjs/ruby_rhino_runtime.rb, line 44 def unbox(value) case value = ::Rhino::To.ruby(value) when ::Rhino::NativeFunction nil when ::Rhino::NativeObject value.inject({}) do |vs, (k, v)| case v when ::Rhino::NativeFunction, ::Rhino::J::Function nil else vs[k] = unbox(v) end vs end when Array value.map { |v| unbox(v) } else value end end
Generated with the Darkfish Rdoc Generator 2.