Sha256: 46769aa96c67849b58f8fbb59d3d299ed7f760d976de86eab70b353abb82304c

Contents?: true

Size: 666 Bytes

Versions: 12

Compression:

Stored size: 666 Bytes

Contents

class Object
  # http://www.yohasebe.com/pages/trans-seeing-metaclasses-clearly/
  def metaclass
    class << self
      self
    end
  end
 
  # http://www.yohasebe.com/pages/trans-seeing-metaclasses-clearly/
  def meta_eval(&blk)
    metaclass.instance_eval(&blk)
  end
 
  # http://www.yohasebe.com/pages/trans-seeing-metaclasses-clearly/
  def meta_def(name, &blk)
   meta_eval { define_method name, &blk }
  end
 
  # http://www.yohasebe.com/pages/trans-seeing-metaclasses-clearly/
  def class_def(name, &blk)
    class_eval { define_method name, &blk }
  end
  
  # 1.8.7  エミュレート
  # TODO version 指定
  def tap
    yield(self)
    self
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
kanamei-keystone-0.0.15 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.16 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.17 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.18 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.19 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.20 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.21 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.22 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.23 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.24 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.25 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.26 lib/keystone/core_ext/object.rb