Class: MethodCallRecorder
- Inherits:
-
Object
- Object
- MethodCallRecorder
- Defined in:
- lib/method_call_recorder.rb,
lib/method_call_recorder/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#recorded ⇒ Object
Returns the value of attribute recorded.
Instance Method Summary collapse
-
#initialize ⇒ MethodCallRecorder
constructor
A new instance of MethodCallRecorder.
- #method_missing(name, *args, &block) ⇒ Object
- #replay(subject) ⇒ Object
Constructor Details
#initialize ⇒ MethodCallRecorder
Returns a new instance of MethodCallRecorder.
5 6 7 |
# File 'lib/method_call_recorder.rb', line 5 def initialize @recorded = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
15 16 17 |
# File 'lib/method_call_recorder.rb', line 15 def method_missing(name, *args, &block) @recorded << [name, args, block] end |
Instance Attribute Details
#recorded ⇒ Object
Returns the value of attribute recorded.
4 5 6 |
# File 'lib/method_call_recorder.rb', line 4 def recorded @recorded end |
Instance Method Details
#replay(subject) ⇒ Object
9 10 11 12 13 |
# File 'lib/method_call_recorder.rb', line 9 def replay(subject) recorded.each do |name, args, block| subject.send(name, *args, &block) end end |