Sha256: bb6bda5763dfe5a4c38b7c402cacf469ec433f6f0553787be752d0d5c8316f74

Contents?: true

Size: 573 Bytes

Versions: 53

Compression:

Stored size: 573 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

  instance_methods.reject { |m| m =~ /^__/ || m.to_s == 'object_id' }.each { |m| undef_method m }

  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

53 entries across 53 versions & 1 rubygems

Version Path
hobo_support-2.2.6 lib/hobo_support/methodphitamine.rb
hobo_support-2.2.5 lib/hobo_support/methodphitamine.rb
hobo_support-2.2.4 lib/hobo_support/methodphitamine.rb
hobo_support-2.2.3 lib/hobo_support/methodphitamine.rb
hobo_support-2.2.2 lib/hobo_support/methodphitamine.rb
hobo_support-2.2.1 lib/hobo_support/methodphitamine.rb
hobo_support-2.2.0 lib/hobo_support/methodphitamine.rb
hobo_support-2.1.2 lib/hobo_support/methodphitamine.rb
hobo_support-2.1.1 lib/hobo_support/methodphitamine.rb
hobo_support-2.1.0 lib/hobo_support/methodphitamine.rb
hobo_support-2.1.0.pre4 lib/hobo_support/methodphitamine.rb
hobo_support-2.1.0.pre3 lib/hobo_support/methodphitamine.rb
hobo_support-2.1.0.pre2 lib/hobo_support/methodphitamine.rb
hobo_support-2.1.0.pre1 lib/hobo_support/methodphitamine.rb
hobo_support-2.0.1 lib/hobo_support/methodphitamine.rb
hobo_support-2.0.0 lib/hobo_support/methodphitamine.rb
hobo_support-2.0.0.pre10 lib/hobo_support/methodphitamine.rb
hobo_support-2.0.0.pre9 lib/hobo_support/methodphitamine.rb
hobo_support-2.0.0.pre8 lib/hobo_support/methodphitamine.rb
hobo_support-1.3.3 lib/hobo_support/methodphitamine.rb