From 7898e2666a9b0a7d0e39c7095c6f42aba28bb4fb Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Thu, 7 Jun 2012 11:47:46 -0500 Subject: [PATCH] allow creation of bare V8::Object. --- lib/v8/conversion.rb | 2 +- lib/v8/object.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/v8/conversion.rb b/lib/v8/conversion.rb index fc15e71..9751738 100644 --- a/lib/v8/conversion.rb +++ b/lib/v8/conversion.rb @@ -69,7 +69,7 @@ end class Hash def to_v8 - object = V8::Object.new(V8::C::Object::New()) + object = V8::Object.new each do |key, value| object[key] = value end diff --git a/lib/v8/object.rb b/lib/v8/object.rb index fdbe628..9f72aed 100644 --- a/lib/v8/object.rb +++ b/lib/v8/object.rb @@ -2,9 +2,9 @@ class V8::Object include Enumerable attr_reader :native - def initialize(native) - @native = native - @context = V8::Context.current + def initialize(native = nil) + @context = V8::Context.current or fail "tried to initialize a #{self.class} without being in an entered V8::Context" + @native = native || V8::C::Object::New() end def [](key)