Class: Billy::RequestLog
- Inherits:
-
Object
- Object
- Billy::RequestLog
- Defined in:
- lib/billy/handlers/request_log.rb
Instance Attribute Summary collapse
-
#requests ⇒ Object
readonly
Returns the value of attribute requests.
Instance Method Summary collapse
- #complete(request, handler) ⇒ Object
-
#initialize ⇒ RequestLog
constructor
A new instance of RequestLog.
- #record(method, url, headers, body) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize ⇒ RequestLog
Returns a new instance of RequestLog.
5 6 7 |
# File 'lib/billy/handlers/request_log.rb', line 5 def initialize @requests = [] end |
Instance Attribute Details
#requests ⇒ Object (readonly)
Returns the value of attribute requests.
3 4 5 |
# File 'lib/billy/handlers/request_log.rb', line 3 def requests @requests end |
Instance Method Details
#complete(request, handler) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/billy/handlers/request_log.rb', line 29 def complete(request, handler) return unless Billy.config.record_requests request.merge! status: :complete, handler: handler end |
#record(method, url, headers, body) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/billy/handlers/request_log.rb', line 13 def record(method, url, headers, body) return unless Billy.config.record_requests request = { status: :inflight, handler: nil, method: method, url: url, headers: headers, body: body } @requests.push(request) request end |
#reset ⇒ Object
9 10 11 |
# File 'lib/billy/handlers/request_log.rb', line 9 def reset @requests = [] end |