Sha256: cdc443fb9e7597106f1b5dc5beb311f978d44ea15811140a8f1ba125a97a7d9f

Contents?: true

Size: 464 Bytes

Versions: 90

Compression:

Stored size: 464 Bytes

Contents

# Thanks to _why

class Object

  def metaclass; class << self; self; end; end

  def meta_eval(src=nil, &blk)
    if src
      metaclass.instance_eval(src)
    else
      metaclass.instance_eval &blk
    end
  end

  def metaclass_eval(src=nil, &blk)
    if src
      metaclass.class_eval(src)
    else
      metaclass.class_eval &blk
    end
  end

  # Adds methods to a metaclass
  def meta_def(name, &blk)
    meta_eval { define_method name, &blk }
  end

end

Version data entries

90 entries across 90 versions & 2 rubygems

Version Path
hobo_support-1.3.0.RC2 lib/hobo_support/metaid.rb
hobo_support-1.3.0.RC1 lib/hobo_support/metaid.rb
hobo_support-1.3.0.RC lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre31 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre29 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre28 lib/hobo_support/metaid.rb
hobosupport-1.0.3 lib/hobo_support/metaid.rb
hobosupport-1.1.0.pre4 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre27 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre26 lib/hobo_support/metaid.rb
hobosupport-1.1.0.pre3 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre25 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre24 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre23 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre22 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre21 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre20 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre19 lib/hobo_support/metaid.rb
hobo_support-1.3.0.pre18 lib/hobo_support/metaid.rb
hobosupport-1.1.0.pre2 lib/hobo_support/metaid.rb