Sha256: 1800bf0f01df75202598ec294ab5965c9795afcface6f112d1cf831f03d02bd8

Contents?: true

Size: 729 Bytes

Versions: 27

Compression:

Stored size: 729 Bytes

Contents

# A set of methods to help create meta-programming gizmos.
class Object
  # The metaclass is the singleton behind every object.  
  def metaclass
    class << self
      self
    end
  end

  # Evaluates the block in the context of the metaclass
  def meta_eval &blk
    metaclass.instance_eval &blk
  end

  # Acts like an include except it adds the module's methods
  # to the metaclass so they act like class methods.
  def meta_include mod
    meta_eval do
      include mod
    end
  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

27 entries across 27 versions & 4 rubygems

Version Path
curzonj-icalendar-1.0.2.1 lib/meta.rb
curzonj-icalendar-1.0.2 lib/meta.rb
curzonj-icalendar-1.1.0.2 lib/meta.rb
paulsm-icalendar-1.1.0.4 lib/meta.rb
sdague-icalendar-1.0.2.1 lib/meta.rb
sdague-icalendar-1.0.2.2 lib/meta.rb
sdague-icalendar-1.0.2.3 lib/meta.rb
sdague-icalendar-1.0.2.4 lib/meta.rb
sdague-icalendar-1.1.0.1 lib/meta.rb
sdague-icalendar-1.1.0.2 lib/meta.rb
sdague-icalendar-1.1.0.3 lib/meta.rb
sdague-icalendar-1.1.0 lib/meta.rb
icalendar-1.1.5 lib/meta.rb
icalendar-1.1.4 lib/meta.rb
icalendar-1.1.3 lib/meta.rb
icalendar-1.1.2 lib/meta.rb
icalendar-1.1.1 lib/meta.rb
icalendar-0.96.2 lib/meta.rb
icalendar-0.96.4 lib/meta.rb
icalendar-0.96.3 lib/meta.rb