Class: Object

Inherits:
BasicObject
Defined in:
lib/override.rb

Overview

Metaid == a few simple metaclass helper (See whytheluckystiff.net/articles/seeingMetaclassesClearly.html.)

Instance Method Summary collapse

Instance Method Details

#class_def(name, &blk) ⇒ Object

Defines an instance method within a class



41
42
43
# File 'lib/override.rb', line 41

def class_def name, &blk
  class_eval { define_method name, &blk }
end

#meta_def(name, &blk) ⇒ Object

Adds methods to a metaclass



36
37
38
# File 'lib/override.rb', line 36

def meta_def name, &blk
  meta_eval { define_method name, &blk }
end

#meta_eval(&blk) ⇒ Object



33
# File 'lib/override.rb', line 33

def meta_eval &blk; metaclass.instance_eval &blk; end

#metaclassObject

The hidden singleton lurks behind everyone



32
# File 'lib/override.rb', line 32

def metaclass; class << self; self; end; end