Sha256: dee6753d79b7d6104b859b118f8d57066c94192dca21996b0b63d73ff0e7ed84

Contents?: true

Size: 454 Bytes

Versions: 10

Compression:

Stored size: 454 Bytes

Contents

class Object
  
  ##
  # Return the metaclass of this object.
  
  def metaclass
    class << self; self end
  end
  
  ##
  # Evaluate a +string+ or +block+ in context to this
  # object metaclass.
  
  def meta_eval string = nil, &block
    return metaclass.class_eval(string) if string
    metaclass.class_eval &block
  end
  
  ##
  # Define a singleton method.
  
  def meta_def name, &block
    meta_eval { define_method name, &block }
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
visionmedia-rext-0.0.4 lib/rext/object/metaclass.rb
visionmedia-rext-0.0.5 lib/rext/object/metaclass.rb
visionmedia-rext-0.0.6 lib/rext/object/metaclass.rb
visionmedia-rext-0.0.7 lib/rext/object/metaclass.rb
visionmedia-rext-0.0.8 lib/rext/object/metaclass.rb
visionmedia-rext-0.1.0 lib/rext/object/metaclass.rb
visionmedia-rext-0.2.1 lib/rext/object/metaclass.rb
visionmedia-rext-0.2.2 lib/rext/object/metaclass.rb
visionmedia-rext-0.3.0 lib/rext/object/metaclass.rb
visionmedia-rext-0.3.1 lib/rext/object/metaclass.rb