Class: MockServer::WebSocketFrameMatcher
- Inherits:
-
Object
- Object
- MockServer::WebSocketFrameMatcher
- Defined in:
- lib/mockserver/models.rb
Overview
A per-incoming-frame response rule for a WebSocket mock (mirrors the server
WebSocketMessageMatcher). When frame_type (TEXT / BINARY / PING / PONG / ANY)
and the optional text_matcher match an inbound frame, the rule's responses
(each a WebSocketMessage) are sent back.
Instance Attribute Summary collapse
-
#frame_type ⇒ Object
Returns the value of attribute frame_type.
-
#responses ⇒ Object
Returns the value of attribute responses.
-
#text_matcher ⇒ Object
Returns the value of attribute text_matcher.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(frame_type: nil, text_matcher: nil, responses: nil) ⇒ WebSocketFrameMatcher
constructor
A new instance of WebSocketFrameMatcher.
- #to_h ⇒ Object
Constructor Details
#initialize(frame_type: nil, text_matcher: nil, responses: nil) ⇒ WebSocketFrameMatcher
Returns a new instance of WebSocketFrameMatcher.
1454 1455 1456 1457 1458 |
# File 'lib/mockserver/models.rb', line 1454 def initialize(frame_type: nil, text_matcher: nil, responses: nil) @frame_type = frame_type @text_matcher = text_matcher @responses = responses end |
Instance Attribute Details
#frame_type ⇒ Object
Returns the value of attribute frame_type.
1452 1453 1454 |
# File 'lib/mockserver/models.rb', line 1452 def frame_type @frame_type end |
#responses ⇒ Object
Returns the value of attribute responses.
1452 1453 1454 |
# File 'lib/mockserver/models.rb', line 1452 def responses @responses end |
#text_matcher ⇒ Object
Returns the value of attribute text_matcher.
1452 1453 1454 |
# File 'lib/mockserver/models.rb', line 1452 def text_matcher @text_matcher end |
Class Method Details
.from_hash(data) ⇒ Object
1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 |
# File 'lib/mockserver/models.rb', line 1468 def self.from_hash(data) return nil if data.nil? responses_data = data['responses'] responses = responses_data&.map { |r| WebSocketMessage.from_hash(r) } new( frame_type: data['frameType'], text_matcher: data['textMatcher'], responses: responses ) end |
Instance Method Details
#to_h ⇒ Object
1460 1461 1462 1463 1464 1465 1466 |
# File 'lib/mockserver/models.rb', line 1460 def to_h result = {} result['frameType'] = @frame_type unless @frame_type.nil? result['textMatcher'] = @text_matcher unless @text_matcher.nil? result['responses'] = @responses&.map(&:to_h) if @responses result end |