Sha256: 0899d7761dc84680d0f91290c485a507d6ce9b1cbca7a18efd54711ca87cb52e

Contents?: true

Size: 467 Bytes

Versions: 2

Compression:

Stored size: 467 Bytes

Contents

# From: http://jicksta.com/articles/2007/08/04/the-methodphitamine

module Kernel

  def it() It.new end
  alias its it
  
end

class It < BlankSlate

  def initialize
    @methods = []
  end

  def method_missing(*args, &block)
    @methods << [args, block] unless args == [:respond_to?, :to_proc]
    self
  end

  def to_proc
    lambda do |obj|
      @methods.inject(obj) do |current,(args,block)|
        current.send(*args, &block)
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
hobo-support-0.1 lib/hobosupport/methodphitamine.rb
hobosupport-0.1 lib/hobosupport/methodphitamine.rb