summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorXavier Noria <[email protected]>2024-03-09 14:00:02 +0100
committerNobuyoshi Nakada <[email protected]>2024-03-15 22:21:43 +0900
commit077ac25ed8c699724467f209cf8df84b4abf9768 ()
treeed1238e8c7740e165cbedffd192ef53128eb378b /variable.c
parent9284fe123ef583ec4ba09097bcc795a54b1f5cf7 (diff)
Iterate the documentation of Module.const_missing
-rw-r--r--variable.c25
1 files changed, 15 insertions, 10 deletions
@@ -2300,23 +2300,28 @@ rb_const_missing(VALUE klass, VALUE name)
*
* Foo::UNDEFINED_CONST #=> :UNDEFINED_CONST: symbol returned
*
- * In the next example when a reference is made to an undefined constant,
- * it attempts to load a file whose name is the lowercase version of the
- * constant (thus class <code>Fred</code> is assumed to be in file
- * <code>fred.rb</code>). If found, it returns the loaded class. It
- * therefore implements an autoload feature similar to Kernel#autoload and
- * Module#autoload.
*
* def Object.const_missing(name)
* @looked_for ||= {}
* str_name = name.to_s
- * raise "Class not found: #{name}" if @looked_for[str_name]
* @looked_for[str_name] = 1
* file = str_name.downcase
* require file
- * klass = const_get(name)
- * return klass if klass
- * raise "Class not found: #{name}"
* end
*
*/