diff options
Diffstat (limited to 'lib/json/common.rb')
-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 2f1584e..3ce25c1 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 |