Class: SSHake::RecordedSession
- Inherits:
-
BaseSession
- Object
- BaseSession
- SSHake::RecordedSession
- Defined in:
- lib/sshake/recorded_session.rb
Instance Attribute Summary collapse
-
#recorder ⇒ Object
readonly
Returns the value of attribute recorder.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Attributes inherited from BaseSession
#id, #klogger, #raise_on_error
Instance Method Summary collapse
- #execute(commands, options = nil, &block) ⇒ Object
-
#initialize(recorder, session, **options) ⇒ RecordedSession
constructor
A new instance of RecordedSession.
Methods inherited from BaseSession
#connect, #connected?, #disconnect, #kill!, #write_data
Constructor Details
#initialize(recorder, session, **options) ⇒ RecordedSession
Returns a new instance of RecordedSession.
13 14 15 16 17 |
# File 'lib/sshake/recorded_session.rb', line 13 def initialize(recorder, session, **) super @recorder = recorder @session = session end |
Instance Attribute Details
#recorder ⇒ Object (readonly)
Returns the value of attribute recorder.
10 11 12 |
# File 'lib/sshake/recorded_session.rb', line 10 def recorder @recorder end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
11 12 13 |
# File 'lib/sshake/recorded_session.rb', line 11 def session @session end |
Instance Method Details
#execute(commands, options = nil, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sshake/recorded_session.rb', line 19 def execute(commands, = nil, &block) = (, block) command_to_execute = prepare_commands(commands, ) cached_response = @recorder.play(command_to_execute, options: , connection: connection_hash) return cached_response if cached_response response = @session.execute(commands, ) record(command_to_execute, , response) response end |