mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Fix mustang unboxing
This commit is contained in:
parent
23619501ca
commit
4682bce11c
1 changed files with 10 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue