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