mirror of
https://github.com/rubyjs/therubyracer
synced 2023-03-27 23:21:42 -04:00
add dynamic property access via the [] and []= methods.
This commit is contained in:
parent
4e83c7b889
commit
25f1d91b3f
2 changed files with 9 additions and 2 deletions
|
@ -107,6 +107,8 @@ module V8
|
|||
else
|
||||
To.v8(method)
|
||||
end
|
||||
elsif obj.respond_to?(:[])
|
||||
To.v8(obj[name])
|
||||
else
|
||||
C::Empty
|
||||
end
|
||||
|
@ -116,11 +118,15 @@ module V8
|
|||
class NamedPropertySetter
|
||||
def self.call(property, value, info)
|
||||
obj = To.rb(info.This())
|
||||
setter = To.rb(property) + "="
|
||||
name = To.rb(property)
|
||||
setter = name + "="
|
||||
methods = accessible_methods(obj)
|
||||
if methods.include?(setter)
|
||||
obj.send(setter, To.rb(value))
|
||||
value
|
||||
elsif obj.respond_to?(:[]=)
|
||||
obj.send(:[]=, name, To.rb(value))
|
||||
value
|
||||
else
|
||||
C::Empty
|
||||
end
|
||||
|
@ -187,6 +193,7 @@ module V8
|
|||
break if ancestor == ::Object
|
||||
methods.merge(ancestor.public_instance_methods(false).map {|m| m.to_s})
|
||||
end
|
||||
methods.reject! {|m| m == "[]" || m == "[]="}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7587bc34da1f2944393e312bf4f1911218375b4a
|
||||
Subproject commit 9ff9293c6d55d9276c3512221c4fdb912808564a
|
Loading…
Add table
Reference in a new issue