Class: RecursiveSpy
- Inherits:
-
Object
- Object
- RecursiveSpy
- Defined in:
- lib/recursive_spy.rb
Defined Under Namespace
Classes: MethodInvocation
Instance Attribute Summary collapse
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
Instance Method Summary collapse
-
#initialize ⇒ RecursiveSpy
constructor
A new instance of RecursiveSpy.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize ⇒ RecursiveSpy
Returns a new instance of RecursiveSpy.
4 5 6 |
# File 'lib/recursive_spy.rb', line 4 def initialize @calls = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/recursive_spy.rb', line 8 def method_missing(method, *args) value = self.class.new @calls[method] ||= [] @calls[method] << MethodInvocation.new( value, args ) value end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
2 3 4 |
# File 'lib/recursive_spy.rb', line 2 def calls @calls end |