Class: Methodphitamine::It
- Inherits:
-
Object
- Object
- Methodphitamine::It
- Defined in:
- lib/methodphitamine/it_class.rb
Overview
The class instantiated by the it() and its() methods from monkey_patches.rb.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ It
constructor
A new instance of It.
- #method_missing(*args, &block) ⇒ Object
-
#methodphitamine_queue ⇒ Object
Used for testing this class.
- #to_proc ⇒ Object
Constructor Details
#initialize ⇒ It
Returns a new instance of It.
19 20 21 |
# File 'lib/methodphitamine/it_class.rb', line 19 def initialize @methods = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
23 24 25 26 |
# File 'lib/methodphitamine/it_class.rb', line 23 def method_missing(*args, &block) @methods << [args, block] unless args == [:respond_to?, :to_proc] self end |
Instance Method Details
#methodphitamine_queue ⇒ Object
Used for testing this class.
37 38 39 |
# File 'lib/methodphitamine/it_class.rb', line 37 def methodphitamine_queue @methods end |
#to_proc ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/methodphitamine/it_class.rb', line 28 def to_proc lambda do |obj| @methods.inject(obj) do |current,(args,block)| current.send(*args, &block) end end end |