diff --git a/lib/v8/access.rb b/lib/v8/access.rb index 6632356..8ece3f7 100644 --- a/lib/v8/access.rb +++ b/lib/v8/access.rb @@ -15,7 +15,7 @@ module V8 if method_name method = obj.method(method_name) if method.arity == 0 - To.v8(method.call()) + Function.rubycall(method) else To.v8(method) end diff --git a/lib/v8/function.rb b/lib/v8/function.rb index 67311ea..e919d38 100644 --- a/lib/v8/function.rb +++ b/lib/v8/function.rb @@ -14,5 +14,14 @@ module V8 raise err if err return return_value end + + def self.rubycall(rubycode, *args) + begin + To.v8(rubycode.call(*args)) + rescue StandardError => e + V8::C::ThrowException(V8::C::Exception::Error(V8::C::String::New(e.message))) + end + end + end end \ No newline at end of file diff --git a/lib/v8/to.rb b/lib/v8/to.rb index a28e6d2..d0c9d48 100644 --- a/lib/v8/to.rb +++ b/lib/v8/to.rb @@ -28,11 +28,7 @@ module V8 for i in 0..arguments.Length() - 1 rbargs << To.ruby(arguments[i]) end - begin - To.v8(value.call(*rbargs)) - rescue StandardError => e - V8::C::ThrowException(V8::C::Exception::Error(V8::C::String::New(e.message))) - end + V8::Function.rubycall(value, *rbargs) end return template.GetFunction() when ::Array