【发布时间】:2015-05-20 21:36:15
【问题描述】:
我可以取消定义 Bar (How to undefine class in Ruby?),但是如何取消定义 Foo::Bar?
irb(main):266:0> Object.send :remove_const, :ActiveRecord::Base
TypeError: :ActiveRecord is not a class/module
irb(main):267:0> Object.send :remove_const, :"ActiveRecord::Base"
NameError: `ActiveRecord::Base' is not allowed as a constant name
irb(main):269:0> module ActiveRecord; Object.send :remove_const, :Base; end
NameError: constant Object::Base not defined
【问题讨论】:
标签: ruby