Method: ActiveSupport::Dependencies#remove_constant
- Defined in:
- activesupport/lib/active_support/dependencies.rb
#remove_constant(const) ⇒ Object
:nodoc:
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 |
# File 'activesupport/lib/active_support/dependencies.rb', line 668 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 |