为什么#constants返回一个空数组?

时间:2013-09-14 15:49:54

标签: ruby

鉴于这样的课程结构:

class Notifiers::NotifierBase
  def initialize
  end

end

module Notifiers
  module Profile
    class TipNotifier < NotifierBase
    end
  end
end

当我运行时Notifiers::Profile.constants []被退回。我不应该看到类常量TipNotifier

如果我调用Notifiers::Profile::TipNotifier,那么如果我调用Notifiers::Profile.constants,我会将此对象作为数组的一部分返回。 [:TipNotifier]。我在这里错过了什么?

也许我应该补充一点,这些示例是作为Rails项目中全局命名空间的一部分包含在文件中的。 BaseNotifier是全局命名空间的一部分。

0 个答案:

没有答案
相关问题