Method: JSON.deep_const_get
- Defined in:
- lib/crazy_ivan/vendor/json-1.1.7/lib/json/common.rb
.deep_const_get(path) ⇒ Object
Return the constant located at path. The format of path has to be either ::A::B::C or A::B::C. In any case A has to be located at the top level (absolute namespace path?). If there doesn’t exist a constant at the given path, an ArgumentError is raised.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/crazy_ivan/vendor/json-1.1.7/lib/json/common.rb', line 34 def deep_const_get(path) # :nodoc: path = path.to_s path.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}" end end end |