Ruby 2.3.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