Sha256: 46df3a1351ef134e1051fb9941cf314de84d8092b24273cf644c482d24f03160

Contents?: true

Size: 747 Bytes

Versions: 3

Compression:

Stored size: 747 Bytes

Contents

# -*- coding: utf-8 -*-
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
  # 
  def tapp
    self.tap{|obj| p obj}
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
keystone-0.0.32 lib/keystone/core_ext/object.rb
keystone-0.0.31 lib/keystone/core_ext/object.rb
keystone-0.0.30 lib/keystone/core_ext/object.rb