@api semipublic
# File lib/dm-core/support/ext/module.rb, line 5 5: def self.find_const(mod, const_name) 6: if const_name[0..1] == '::' 7: DataMapper::Ext::Object.full_const_get(const_name[2..1]) 8: else 9: nested_const_lookup(mod, const_name) 10: end 11: end
Doesn’t do any caching since constants can change with remove_const
# File lib/dm-core/support/ext/module.rb, line 16 16: def self.nested_const_lookup(mod, const_name) 17: unless mod.equal?(::Object) 18: constants = [] 19: 20: mod.name.split('::').each do |part| 21: const = constants.last || ::Object 22: constants << const.const_get(part) 23: end 24: 25: parts = const_name.split('::') 26: 27: # from most to least specific constant, use each as a base and try 28: # to find a constant with the name const_name within them 29: constants.reverse_each do |const| 30: # return the nested constant if available 31: return const if parts.all? do |part| 32: const = if RUBY_VERSION >= '1.9.0' 33: const.const_defined?(part, false) ? const.const_get(part, false) : nil 34: else 35: const.const_defined?(part) ? const.const_get(part) : nil 36: end 37: end 38: end 39: end 40: 41: # no relative constant found, fallback to an absolute lookup and 42: # use const_missing if not found 43: DataMapper::Ext::Object.full_const_get(const_name) 44: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.