Sha256: bf9b7e456eff6126961c49fd5ea859fd12ac68c485484fd979ac4044b0bec2cf

Contents?: true

Size: 642 Bytes

Versions: 5

Compression:

Stored size: 642 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  エミュレート
  def tap
    yield(self)
    self
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
kanamei-kanamei-keystone-0.0.12 lib/keystone/core_ext/object.rb
kanamei-kanamei-keystone-0.0.13 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.11 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.12 lib/keystone/core_ext/object.rb
kanamei-keystone-0.0.14 lib/keystone/core_ext/object.rb