Sha256: a55e9cddac29a1f3bf995e04c000dd58ad9f02278ace57fddd3c3259a017888d
Contents?: true
Size: 474 Bytes
Versions: 3
Compression:
Stored size: 474 Bytes
Contents
# from http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html class Object # The hidden singleton lurks behind everyone def metaclass; class << self; self; end; end def meta_eval &blk; metaclass.instance_eval &blk; end # Adds methods to a metaclass def meta_def name, &blk meta_eval { define_method name, &blk } end # Defines an instance method within a class def class_def name, &blk class_eval { define_method name, &blk } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ramaze-0.3.5 | lib/ramaze/snippets/metaid.rb |
ramaze-0.3.9 | lib/ramaze/snippets/metaid.rb |
ramaze-0.3.9.1 | lib/ramaze/snippets/metaid.rb |