1
0
Fork 0
mirror of https://github.com/rails/execjs synced 2023-03-27 23:21:20 -04:00

Fix mustang unboxing

This commit is contained in:
Joshua Peek 2011-04-12 11:36:21 -05:00
parent 23619501ca
commit 4682bce11c

View file

@ -20,20 +20,24 @@ module ExecJS
def call(properties, *args)
unbox @v8_context.eval(properties).call(*args)
rescue NoMethodError
raise ProgramError
rescue NoMethodError => e
raise ProgramError, e.message
end
def unbox(value)
case value
when Mustang::V8::NullClass, Mustang::V8::UndefinedClass, Mustang::V8::Function
nil
when Mustang::V8::Array
value.map { |v| unbox(v) }
when Mustang::V8::Boolean
value.to_bool
when Mustang::V8::NullClass, Mustang::V8::UndefinedClass
nil
when Mustang::V8::Function
nil
when Mustang::V8::SyntaxError
raise RuntimeError
raise RuntimeError, value.message
when Mustang::V8::Error
raise ProgramError
raise ProgramError, value.message
else
value.respond_to?(:delegate) ? value.delegate : value
end