Class: Browserctl::Client::RecordingInterceptor
- Inherits:
-
Object
- Object
- Browserctl::Client::RecordingInterceptor
- Defined in:
- lib/browserctl/client/recording_interceptor.rb
Overview
Bridges Client#call to the Recording subsystem. Keeps Client itself a pure IPC shim — Recording is pluggable via constructor injection.
Instance Method Summary collapse
-
#active? ⇒ Boolean
Whether recording is currently active.
-
#append(cmd, response:, params: {}) ⇒ Object
Called after a successful Client#call to append the command and response to the active recording log.
-
#capture_post_snapshot_flag ⇒ Object
Returns ‘true` when active, `nil` otherwise.
-
#initialize(recording: Browserctl::Recording) ⇒ RecordingInterceptor
constructor
A new instance of RecordingInterceptor.
Constructor Details
#initialize(recording: Browserctl::Recording) ⇒ RecordingInterceptor
Returns a new instance of RecordingInterceptor.
10 11 12 |
# File 'lib/browserctl/client/recording_interceptor.rb', line 10 def initialize(recording: Browserctl::Recording) @recording = recording end |
Instance Method Details
#active? ⇒ Boolean
Whether recording is currently active. Call sites that need to vary their request shape (e.g. click/fill passing capture_post_snapshot:) can ask without touching Recording directly.
17 18 19 |
# File 'lib/browserctl/client/recording_interceptor.rb', line 17 def active? @recording.active end |
#append(cmd, response:, params: {}) ⇒ Object
Called after a successful Client#call to append the command and response to the active recording log. No-op if the response was not ok (recording only captures successful interactions).
32 33 34 35 36 |
# File 'lib/browserctl/client/recording_interceptor.rb', line 32 def append(cmd, response:, params: {}) return unless response[:ok] @recording.append(cmd, response: response, **params) end |
#capture_post_snapshot_flag ⇒ Object
Returns ‘true` when active, `nil` otherwise. Matches the shape that click/fill historically passed as the `capture_post_snapshot` param.
23 24 25 26 27 |
# File 'lib/browserctl/client/recording_interceptor.rb', line 23 def capture_post_snapshot_flag return true if active? nil end |