Sha256: f303934516c1d0269d2de96c377a85641643337077427879311e5a1c17911b90

Contents?: true

Size: 575 Bytes

Versions: 25

Compression:

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

25 entries across 25 versions & 2 rubygems

Version Path
hobosupport-1.1.0 lib/hobo_support/methodphitamine.rb
hobosupport-1.0.3 lib/hobo_support/methodphitamine.rb
hobosupport-1.1.0.pre4 lib/hobo_support/methodphitamine.rb
hobosupport-1.1.0.pre3 lib/hobo_support/methodphitamine.rb
hobo_support-1.3.0.pre19 lib/hobo_support/methodphitamine.rb
hobo_support-1.3.0.pre18 lib/hobo_support/methodphitamine.rb
hobosupport-1.1.0.pre2 lib/hobo_support/methodphitamine.rb
hobosupport-1.1.0.pre0 lib/hobo_support/methodphitamine.rb
hobosupport-1.0.2 lib/hobo_support/methodphitamine.rb
hobo_support-1.3.0.pre16 lib/hobo_support/methodphitamine.rb
hobo_support-1.3.0.pre15 lib/hobo_support/methodphitamine.rb
hobo_support-1.3.0.pre14 lib/hobo_support/methodphitamine.rb
hobo_support-1.3.0.pre13 lib/hobo_support/methodphitamine.rb
hobo_support-1.3.0.pre12 lib/hobo_support/methodphitamine.rb
hobo_support-1.3.0.pre11 lib/hobo_support/methodphitamine.rb
hobo_support-1.3.0.pre10 lib/hobo_support/methodphitamine.rb
hobosupport-1.0.1 lib/hobo_support/methodphitamine.rb
hobosupport-1.0.0 lib/hobo_support/methodphitamine.rb
hobosupport-0.9.106 lib/hobo_support/methodphitamine.rb
hobosupport-0.9.105 lib/hobo_support/methodphitamine.rb