Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/ruby_sync/util/metaid.rb
Overview
This file is extracted from an article published by “why the lucky stiff” at whytheluckystiff.net/articles/seeingMetaclassesClearly.html
Hopefully Why will publish a meta-programming gem later and RubySync can just make that a dependency.
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
21 22 23 |
# File 'lib/ruby_sync/util/metaid.rb', line 21 def class_def name, &blk class_eval { define_method name, &blk } end |
#meta_def(name, &blk) ⇒ Object
Adds methods to a metaclass
16 17 18 |
# File 'lib/ruby_sync/util/metaid.rb', line 16 def name, &blk { define_method name, &blk } end |
#meta_eval(&blk) ⇒ Object
13 |
# File 'lib/ruby_sync/util/metaid.rb', line 13 def (&blk); .instance_eval(&blk); end |
#metaclass ⇒ Object
The hidden singleton lurks behind everyone
12 |
# File 'lib/ruby_sync/util/metaid.rb', line 12 def ; class << self; self; end; end |