Method: Object#meta_def

Defined in:
lib/extra/object.rb

#meta_def(name, &block) ⇒ Object

whytheluckystiff: whytheluckystiff.net/articles/seeingMetaclassesClearly.html

Define an instance method on the metaclass.

Example: s = 'foo'; s.meta_def(:longer) { self * 2 }; s.longer #=> "foofoo"

Returns: A Proc object of the method.



38
39
40
# File 'lib/extra/object.rb', line 38

def meta_def(name, &block)
	meta_eval { define_method(name, &block) }
end