Sha256: de7a5f8a59f54397b8f8e639e6f91bbecf9bb2315e60c294b6ffe7d04f66503f

Contents?: true

Size: 471 Bytes

Versions: 24

Compression:

Stored size: 471 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

24 entries across 24 versions & 2 rubygems

Version Path
automate-it-0.9.2 lib/ext/metaclass.rb
automate-it-0.9.1 lib/ext/metaclass.rb
automate-it-0.9.0 lib/ext/metaclass.rb
automateit-0.71031.2 lib/ext/metaclass.rb
automateit-0.71021 lib/ext/metaclass.rb
automateit-0.71030 lib/ext/metaclass.rb
automateit-0.71031.1 lib/ext/metaclass.rb
automateit-0.71031 lib/ext/metaclass.rb
automateit-0.71101 lib/ext/metaclass.rb
automateit-0.71101.1 lib/ext/metaclass.rb
automateit-0.71103 lib/ext/metaclass.rb
automateit-0.71102 lib/ext/metaclass.rb
automateit-0.71101.2 lib/ext/metaclass.rb
automateit-0.71104 lib/ext/metaclass.rb
automateit-0.71219 lib/ext/metaclass.rb
automateit-0.71221 lib/ext/metaclass.rb
automateit-0.71220 lib/ext/metaclass.rb
automateit-0.71111 lib/ext/metaclass.rb
automateit-0.71112 lib/ext/metaclass.rb
automateit-0.71226.1 lib/ext/metaclass.rb