mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
Set properties on javascript objects which are reflected into ruby.
This commit is contained in:
parent
772fa7d586
commit
441aa30a7f
2 changed files with 9 additions and 3 deletions
|
@ -16,7 +16,7 @@ VALUE v8_Object_New(VALUE clazz) {
|
|||
VALUE v8_Object_Get(VALUE self, VALUE key) {
|
||||
HandleScope handles;
|
||||
Local<Object> obj = V8_Ref_Get<Object>(self);
|
||||
VALUE keystr = rb_funcall(key,rb_intern("to_s"), 0);
|
||||
VALUE keystr = rb_str_to_str(key);
|
||||
Local<Value> value = obj->Get(RB2V8(keystr));
|
||||
return V82RB(value);
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ VALUE v8_Object_Get(VALUE self, VALUE key) {
|
|||
VALUE v8_Object_Set(VALUE self, VALUE key, VALUE value) {
|
||||
HandleScope handles;
|
||||
Local<Object> obj = V8_Ref_Get<Object>(self);
|
||||
VALUE keystr = rb_funcall(key, rb_intern("to_s"), 0);
|
||||
|
||||
VALUE keystr = rb_funcall(key, rb_intern("to_s"), 0);
|
||||
obj->Set(RB2V8(keystr), RB2V8(value));
|
||||
return Qnil;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,13 @@ module V8
|
|||
end
|
||||
|
||||
def [](key)
|
||||
To.ruby(@native.Get(key))
|
||||
To.ruby(@native.Get(key.to_s))
|
||||
end
|
||||
|
||||
def []=(key, value)
|
||||
value.tap do
|
||||
@native.Set(key.to_s, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue