有没有办法“展平”嵌套模块,以便在扩展另一个类或模块时可以使用它们的所有方法?例如:
class User
extend UserStats
end
module UserStats
module Current
def active
where('status = "active"')
end
end
end
我希望能够扩展 UserStats(或 User),以便 UserStats::Current 中的方法可用作 User 的类方法。
我在 UserStats 中试过“extend Current”,但这似乎不起作用。有什么办法吗?
最佳答案
为什么不直接扩展 UserStats::Current
呢?
关于ruby-on-rails - 扩展扩展类的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5227245/