Class: It

Inherits:
Object show all
Defined in:
lib/hobo_support/methodphitamine.rb

Instance Method Summary collapse

Constructor Details

#initializeIt

Returns a new instance of It.



16
17
18
# File 'lib/hobo_support/methodphitamine.rb', line 16

def initialize
  @methods = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



20
21
22
23
# File 'lib/hobo_support/methodphitamine.rb', line 20

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

Instance Method Details

#to_procObject



25
26
27
28
29
30
31
# File 'lib/hobo_support/methodphitamine.rb', line 25

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