Sha256: d0f2b32d6fd1ce0841824b7fed61559370ff964e3261a0c95b1e3f6eea30cb58

Contents?: true

Size: 469 Bytes

Versions: 7

Compression:

Stored size: 469 Bytes

Contents

# 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

7 entries across 7 versions & 1 rubygems

Version Path
automateit-0.70923 lib/ext/metaclass.rb
automateit-0.70928 lib/ext/metaclass.rb
automateit-0.70930 lib/ext/metaclass.rb
automateit-0.71003 lib/ext/metaclass.rb
automateit-0.71006 lib/ext/metaclass.rb
automateit-0.71012 lib/ext/metaclass.rb
automateit-0.71017 lib/ext/metaclass.rb