Class: Rreplay::OutputBuilder
- Inherits:
-
Object
- Object
- Rreplay::OutputBuilder
- Defined in:
- lib/rreplay/replay_runner.rb
Instance Method Summary collapse
- #call(record, result) ⇒ Object
-
#initialize(style: :json) ⇒ OutputBuilder
constructor
A new instance of OutputBuilder.
Constructor Details
#initialize(style: :json) ⇒ OutputBuilder
Returns a new instance of OutputBuilder.
64 65 66 67 68 69 70 71 |
# File 'lib/rreplay/replay_runner.rb', line 64 def initialize(style: :json) @builder = case style when :json method(:build_json) else method(:build_string) end end |
Instance Method Details
#call(record, result) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/rreplay/replay_runner.rb', line 75 def call(record, result) response_hash = { status: result.response.code, headers: record['response']['headers'].reduce({}) do |acc, (key, _)| acc.merge({key => result.response[key]}) end, body: Array(result.response.body).join(''), } @builder.call(record, result.response_time, response_hash) end |