Class: It

Inherits:
BlankSlate show all
Defined in:
lib/hobosupport/methodphitamine.rb

Instance Method Summary collapse

Constructor Details

#initializeIt

Returns a new instance of It.



12
13
14
# File 'lib/hobosupport/methodphitamine.rb', line 12

def initialize
  @methods = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



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

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

Instance Method Details

#to_procObject



21
22
23
24
25
26
27
# File 'lib/hobosupport/methodphitamine.rb', line 21

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