Ruby 编程/语法/钩子
外观
Ruby 提供回调,例如用于识别在(后期)类中定义新方法的时间。
此处提供了已知回调列表。
class Object
def self.const_missing c
p 'missing const was', c
end
end
或更多
class Object
class << self
alias :const_missing_old :const_missing
def const_missing c
p 'const missing is', c
const_missing_old c
end
end
end