method
remove_constant
v3.2.13 -
Show latest stable
- Class:
ActiveSupport::Dependencies
remove_constant(const)public
No documentation available.
# File activesupport/lib/active_support/dependencies.rb, line 667
def remove_constant(const) #:nodoc:
return false unless qualified_const_defined? const
# Normalize ::Foo, Foo, Object::Foo, and ::Object::Foo to Object::Foo
names = const.to_s.sub(/^::(Object)?/, 'Object::').split("::")
to_remove = names.pop
parent = Inflector.constantize(names * '::')
log "removing constant #{const}"
constantized = constantize(const)
constantized.before_remove_const if constantized.respond_to?(:before_remove_const)
parent.instance_eval { remove_const to_remove }
return true
end