lib/v8/object.rb in therubyracer-0.4.3 vs lib/v8/object.rb in therubyracer-0.4.4

- old
+ new

@@ -6,21 +6,33 @@ def initialize(native) @native = native end def [](key) - To.ruby(@native.Get(key.to_s)) + @native.context.open do + To.ruby(@native.Get(key.to_s)) + end end def []=(key, value) value.tap do - @native.Set(key.to_s, value) + @native.context.open do + @native.Set(key.to_s, value) + end end end def each for prop in @native.GetPropertyNames() yield prop, self[prop] end + end + end +end + +class Object + def eval_js(javascript) + V8::Context.open(:with => self) do |cxt| + cxt.eval(javascript) end end end \ No newline at end of file