Ruby 2.5.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Moduleクラス > const_missing
const_missing(name)
[permalink][rdoc]定義されていない定数を参照したときに Ruby インタプリタがこのメソッドを呼びます。
例
class Foo
def Foo.const_missing(id)
warn "undefined constant #{id.inspect}"
end
Bar
end
Foo::Bar
# => undefined constant :Bar
# undefined constant :Bar