Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/starrez_api/object.rb
Overview
Much props to _why and his (poignant) guide This code can originally be found at viewsourcecode.org/why/hacking/seeingMetaclassesClearly.html
Instance Method Summary collapse
-
#class_def(name, &blk) ⇒ Object
Defines an instance method within a class.
-
#meta_def(name, &blk) ⇒ Object
Adds methods to a metaclass.
- #meta_eval(&blk) ⇒ Object
-
#metaclass ⇒ Object
The hidden singleton lurks behind everyone.
Instance Method Details
#class_def(name, &blk) ⇒ Object
Defines an instance method within a class
16 17 18 |
# File 'lib/starrez_api/object.rb', line 16 def class_def name, &blk class_eval { define_method name, &blk } end |
#meta_def(name, &blk) ⇒ Object
Adds methods to a metaclass
11 12 13 |
# File 'lib/starrez_api/object.rb', line 11 def name, &blk { define_method name, &blk } end |
#meta_eval(&blk) ⇒ Object
8 |
# File 'lib/starrez_api/object.rb', line 8 def &blk; .instance_eval &blk; end |
#metaclass ⇒ Object
The hidden singleton lurks behind everyone
7 |
# File 'lib/starrez_api/object.rb', line 7 def ; class << self; self; end; end |