Class: MethodSpy
- Inherits:
-
Object
- Object
- MethodSpy
- Defined in:
- lib/util.rb
Instance Method Summary collapse
-
#initialize(delegate, &block) ⇒ MethodSpy
constructor
A new instance of MethodSpy.
- #method_missing(symbol, *args, &block) ⇒ Object
Constructor Details
#initialize(delegate, &block) ⇒ MethodSpy
Returns a new instance of MethodSpy.
17 18 19 20 |
# File 'lib/util.rb', line 17 def initialize(delegate, &block) @delegate = delegate @filter = block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, &block) ⇒ Object
22 23 24 25 26 |
# File 'lib/util.rb', line 22 def method_missing(symbol, *args, &block) result = @delegate.send(symbol, *args, &block) p [symbol, args, result, block] if @filter && @filter.call(symbol.to_s) result end |