Class: Object

Inherits:
BasicObject
Defined in:
lib/core_ext/object.rb

Instance Method Summary collapse

Instance Method Details

#full_const_get(name) ⇒ Object

Cribbed from DataMapper’s Extlib library.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/core_ext/object.rb', line 4

def full_const_get(name)
  list = name.split("::")
  list.shift if list.first.blank?
  obj = self
  list.each do |x|
    # This is required because const_get tries to look for constants in the
    # ancestor chain, but we only want constants that are HERE
    obj = obj.const_defined?(x) ? obj.const_get(x) : obj.const_missing(x)
  end
  obj
end