Class: It
Instance Method Summary collapse
-
#initialize ⇒ It
constructor
A new instance of It.
- #method_missing(*args, &block) ⇒ Object
- #to_proc ⇒ Object
Constructor Details
#initialize ⇒ It
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_proc ⇒ Object
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 |