Method: Object#class_def
- Defined in:
- lib/extra/object.rb
#class_def(name, &block) ⇒ Object
whytheluckystiff: whytheluckystiff.net/articles/seeingMetaclassesClearly.html
Adds a class instance method.
Example:
SomeClass.class_def(:whoami) { 'I am SomeClass, silly!' }
SomeClass.whoami #=> "I am SomeClass, silly!"
Returns: A Proc object of the method, or nil.
54 55 56 |
# File 'lib/extra/object.rb', line 54 def class_def(name, &block) class_eval { define_method(name, &block) } if kind_of? Class end |