diff options
author | Florian Frank <flori@ping.de> | 2010-04-08 02:40:45 +0200 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2010-04-08 02:40:45 +0200 |
commit | b2a5be0eef9095154cc8c7751d0318a565dad6da (patch) | |
tree | 386b576e336bcd9e6c82b59aaec45c70f56fcb55 /lib | |
parent | c3e8dd92f04b010366e4d7152c83c7486af93e1e (diff) | |
parent | a294a83f4d22901651d09c06063eb20d3b2290b8 (diff) | |
download | json-b2a5be0eef9095154cc8c7751d0318a565dad6da.tar.gz |
Merged in const_missing triggering from v1.2
Merge commit 'a294a83f4d22901651d09c06063eb20d3b2290b8'
Conflicts:
VERSION
lib/json/version.rb
Diffstat (limited to 'lib')
-rw-r--r-- | lib/json/common.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/json/common.rb b/lib/json/common.rb index cd9d1c6..a8aa016 100644 --- a/lib/json/common.rb +++ b/lib/json/common.rb @@ -33,12 +33,16 @@ module JSON # level (absolute namespace path?). If there doesn't exist a constant at # the given path, an ArgumentError is raised. def deep_const_get(path) # :nodoc: - path = path.to_s - path.split(/::/).inject(Object) do |p, c| + path.to_s.split(/::/).inject(Object) do |p, c| case when c.empty? then p when p.const_defined?(c) then p.const_get(c) - else raise ArgumentError, "can't find const #{path}" + else + if (c = p.const_missing(c) rescue nil) + c + else + raise ArgumentError, "can't find const #{path}" + end end end end |