class Object

A set of methods to help create meta-programming gizmos.

Public Instance Methods

class_def(name, &blk) click to toggle source

Defines an instance method within a class

# File lib/meta.rb, line 29
def class_def name, &blk
  class_eval { define_method name, &blk }
end
meta_def(name, &blk) click to toggle source

Adds methods to a metaclass

# File lib/meta.rb, line 24
def meta_def name, &blk
  meta_eval { define_method name, &blk }
end
meta_eval(&blk) click to toggle source

Evaluates the block in the context of the metaclass

# File lib/meta.rb, line 11
def meta_eval(&blk)
  metaclass.instance_eval(&blk)
end
meta_include(mod) click to toggle source

Acts like an include except it adds the module’s methods to the metaclass so they act like class methods.

# File lib/meta.rb, line 17
def meta_include mod
  meta_eval do
    include mod
  end
end
metaclass() click to toggle source

The metaclass is the singleton behind every object.

# File lib/meta.rb, line 4
def metaclass
  class << self
    self
  end
end