Class: MethodCallRecorder

Inherits:
Object
  • Object
show all
Defined in:
lib/method_call_recorder.rb,
lib/method_call_recorder/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMethodCallRecorder

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

#recordedObject

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