Returns the value of the specified constant.
@overload full_const_get(obj, name)
Returns the value of the specified constant in +obj+. @param [Object] obj The root object used as origin. @param [String] name The name of the constant to get, e.g. "Merb::Router".
@overload full_const_get(name)
Returns the value of the fully-qualified constant. @param [String] name The name of the constant to get, e.g. "Merb::Router".
@return [Object] The constant corresponding to name.
@api semipublic
# File lib/dm-core/support/ext/object.rb, line 17 17: def self.full_const_get(obj, name = nil) 18: obj, name = ::Object, obj if name.nil? 19: 20: list = name.split("::") 21: list.shift if DataMapper::Ext.blank?(list.first) 22: list.each do |x| 23: # This is required because const_get tries to look for constants in the 24: # ancestor chain, but we only want constants that are HERE 25: obj = obj.const_defined?(x) ? obj.const_get(x) : obj.const_missing(x) 26: end 27: obj 28: end
Sets the specified constant to the given value.
@overload full_const_set(obj, name)
Sets the specified constant in +obj+ to the given +value+. @param [Object] obj The root object used as origin. @param [String] name The name of the constant to set, e.g. "Merb::Router". @param [Object] value The value to assign to the constant.
@overload full_const_set(name)
Sets the fully-qualified constant to the given +value+. @param [String] name The name of the constant to set, e.g. "Merb::Router". @param [Object] value The value to assign to the constant.
@return [Object] The constant corresponding to name.
@api semipublic
# File lib/dm-core/support/ext/object.rb, line 46 46: def self.full_const_set(obj, name, value = nil) 47: obj, name, value = ::Object, obj, name if value.nil? 48: 49: list = name.split("::") 50: toplevel = DataMapper::Ext.blank?(list.first) 51: list.shift if toplevel 52: last = list.pop 53: obj = list.empty? ? ::Object : DataMapper::Ext::Object.full_const_get(list.join("::")) 54: obj.const_set(last, value) if obj && !obj.const_defined?(last) 55: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.