Class: It
- Inherits:
-
BlankSlate
- Object
- BlankSlate
- It
- Defined in:
- lib/hobosupport/methodphitamine.rb
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.
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_proc ⇒ Object
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 |