Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试编写一个通用模块来扩展 World 类。我需要从模块内访问 Before 和 After 挂钩。我正在使用扩展方法执行此操作,但此时之前/之后似乎不可用。
module MyWorld def MyWorld.extended(obj) obj.Before do # this doesn't work end end end
还有其他方法可以访问这些钩子吗?
了解如何做到这一点:
module MyWorld def MyWorld.extended(obj) Main.Before do # some stuff end Main.After do # some other stuff end end end