Ruby 1.9.2 Reference Manual > All Libraries > Builtin Library > class Module > const_missing
const_missing(name)定義されていない定数を参照したときに Ruby インタプリタが このメソッドを呼びます。
class Foo
def Foo.const_missing(id)
warn "undefined constant #{id.inspect}"
end
Bar
end
Foo::Bar
# => undefined constant :Bar
undefined constant :Bar