Class: MockServer::HttpWebSocketResponse
- Inherits:
-
Object
- Object
- MockServer::HttpWebSocketResponse
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#close_connection ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
-
#delay ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
-
#matchers ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
-
#messages ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
-
#primary ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
-
#subprotocol ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(subprotocol: nil, messages: nil, matchers: nil, close_connection: nil, delay: nil, primary: nil) ⇒ HttpWebSocketResponse
constructor
A new instance of HttpWebSocketResponse.
- #to_h ⇒ Object
Constructor Details
#initialize(subprotocol: nil, messages: nil, matchers: nil, close_connection: nil, delay: nil, primary: nil) ⇒ HttpWebSocketResponse
Returns a new instance of HttpWebSocketResponse.
1486 1487 1488 1489 1490 1491 1492 1493 |
# File 'lib/mockserver/models.rb', line 1486 def initialize(subprotocol: nil, messages: nil, matchers: nil, close_connection: nil, delay: nil, primary: nil) @subprotocol = subprotocol @messages = @matchers = matchers @close_connection = close_connection @delay = delay @primary = primary end |
Instance Attribute Details
#close_connection ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
1484 1485 1486 |
# File 'lib/mockserver/models.rb', line 1484 def close_connection @close_connection end |
#delay ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
1484 1485 1486 |
# File 'lib/mockserver/models.rb', line 1484 def delay @delay end |
#matchers ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
1484 1485 1486 |
# File 'lib/mockserver/models.rb', line 1484 def matchers @matchers end |
#messages ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
1484 1485 1486 |
# File 'lib/mockserver/models.rb', line 1484 def @messages end |
#primary ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
1484 1485 1486 |
# File 'lib/mockserver/models.rb', line 1484 def primary @primary end |
#subprotocol ⇒ Object
matchers carries per-incoming-frame response rules (server HttpWebSocketResponseDTO.matchers); each is a WebSocketFrameMatcher.
1484 1485 1486 |
# File 'lib/mockserver/models.rb', line 1484 def subprotocol @subprotocol end |
Class Method Details
.from_hash(data) ⇒ Object
1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 |
# File 'lib/mockserver/models.rb', line 1506 def self.from_hash(data) return nil if data.nil? = data['messages'] = &.map { |m| WebSocketMessage.from_hash(m) } matchers_data = data['matchers'] matchers = matchers_data&.map { |m| WebSocketFrameMatcher.from_hash(m) } new( subprotocol: data['subprotocol'], messages: , matchers: matchers, close_connection: data['closeConnection'], delay: Delay.from_hash(data['delay']), primary: data['primary'] ) end |
Instance Method Details
#to_h ⇒ Object
1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 |
# File 'lib/mockserver/models.rb', line 1495 def to_h result = {} result['subprotocol'] = @subprotocol unless @subprotocol.nil? result['messages'] = @messages&.map(&:to_h) if @messages result['matchers'] = @matchers&.map(&:to_h) if @matchers result['closeConnection'] = @close_connection unless @close_connection.nil? result['delay'] = @delay.to_h if @delay result['primary'] = @primary unless @primary.nil? result end |