Module: Samuel::Diary

Extended by:
Diary
Included in:
Diary
Defined in:
lib/samuel/diary.rb

Instance Method Summary collapse

Instance Method Details

#current_timeObject



16
17
18
# File 'lib/samuel/diary.rb', line 16

def current_time
  Time.now
end

#record_request(http, request, time_requested = current_time) ⇒ Object



5
6
7
8
# File 'lib/samuel/diary.rb', line 5

def record_request(http, request, time_requested = current_time)
  @requests ||= []
  @requests.push({:request => request, :time_requested => time_requested})
end

#record_response(http, request, response, time_responded = current_time) ⇒ Object



10
11
12
13
14
# File 'lib/samuel/diary.rb', line 10

def record_response(http, request, response, time_responded = current_time)
  time_requested = @requests.detect { |r| r[:request] == request }[:time_requested]
  @requests.reject! { |r| r[:request] == request }
  log_request_and_response(http, request, response, time_requested, time_responded)
end