diff --git a/lib/rhino/native_object.rb b/lib/rhino/native_object.rb index 76d9947..537f963 100644 --- a/lib/rhino/native_object.rb +++ b/lib/rhino/native_object.rb @@ -23,7 +23,7 @@ def initialize(j) # :nodoc: # jsobject['foo'] # => 'bar' # jsobject['Take me to'] # => 'a funky town' def [](k) - To.ruby @j.get(k.to_s, @j) + To.ruby J::ScriptableObject.getProperty(@j,k.to_s) end # set a property on the javascript object, where +k+ is a string or symbol corresponding @@ -36,7 +36,8 @@ def [](k) # end def []=(k,v) - @j.put(k.to_s,@j,To.javascript(v)) + #@j.put(k.to_s,@j,To.javascript(v)) + J::ScriptableObject.putProperty(@j, k.to_s, To.javascript(v)) end # enumerate the key value pairs contained in this javascript object. e.g. diff --git a/spec/rhino/native_object_spec.rb b/spec/rhino/native_object_spec.rb index 592756b..ac0c43e 100644 --- a/spec/rhino/native_object_spec.rb +++ b/spec/rhino/native_object_spec.rb @@ -27,6 +27,18 @@ it "returns nil when the value is null, null, or not defined" do @o[:foo].should be_nil end + + + it "traverses the prototype chain when hash accessing properties from the ruby object" do + Rhino::Context.open do |cxt| + cxt.eval(< 'bar', "bang" => 'baz', 5 => 'flip'} end + + it "should traverse prototype chain when enumerating keys and values" + end end