Sha256: c806e75d2263f97e972c6ebba923e27c42c99966f344ef233a0349b098741ee1

Contents?: true

Size: 487 Bytes

Versions: 12

Compression:

Stored size: 487 Bytes

Contents

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

require 'blankslate'

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

12 entries across 12 versions & 1 rubygems

Version Path
hobosupport-0.9.0 lib/hobo_support/methodphitamine.rb
hobosupport-0.8.10 lib/hobo_support/methodphitamine.rb
hobosupport-0.8.9 lib/hobo_support/methodphitamine.rb
hobosupport-0.8.8 lib/hobo_support/methodphitamine.rb
hobosupport-0.8.3 lib/hobosupport/methodphitamine.rb
hobosupport-0.8.4 lib/hobo_support/methodphitamine.rb
hobosupport-0.8.5 lib/hobo_support/methodphitamine.rb
hobosupport-0.8.6 lib/hobo_support/methodphitamine.rb
hobosupport-0.8.2 lib/hobosupport/methodphitamine.rb
hobosupport-0.8 lib/hobosupport/methodphitamine.rb
hobosupport-0.8.1 lib/hobosupport/methodphitamine.rb
hobosupport-0.8.7 lib/hobo_support/methodphitamine.rb