Class: MockServer::HttpWebSocketResponse
- Inherits:
-
Object
- Object
- MockServer::HttpWebSocketResponse
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#close_connection ⇒ Object
Returns the value of attribute close_connection.
-
#delay ⇒ Object
Returns the value of attribute delay.
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#primary ⇒ Object
Returns the value of attribute primary.
-
#subprotocol ⇒ Object
Returns the value of attribute subprotocol.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(subprotocol: nil, messages: 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, close_connection: nil, delay: nil, primary: nil) ⇒ HttpWebSocketResponse
Returns a new instance of HttpWebSocketResponse.
1116 1117 1118 1119 1120 1121 1122 |
# File 'lib/mockserver/models.rb', line 1116 def initialize(subprotocol: nil, messages: nil, close_connection: nil, delay: nil, primary: nil) @subprotocol = subprotocol @messages = @close_connection = close_connection @delay = delay @primary = primary end |
Instance Attribute Details
#close_connection ⇒ Object
Returns the value of attribute close_connection.
1114 1115 1116 |
# File 'lib/mockserver/models.rb', line 1114 def close_connection @close_connection end |
#delay ⇒ Object
Returns the value of attribute delay.
1114 1115 1116 |
# File 'lib/mockserver/models.rb', line 1114 def delay @delay end |
#messages ⇒ Object
Returns the value of attribute messages.
1114 1115 1116 |
# File 'lib/mockserver/models.rb', line 1114 def @messages end |
#primary ⇒ Object
Returns the value of attribute primary.
1114 1115 1116 |
# File 'lib/mockserver/models.rb', line 1114 def primary @primary end |
#subprotocol ⇒ Object
Returns the value of attribute subprotocol.
1114 1115 1116 |
# File 'lib/mockserver/models.rb', line 1114 def subprotocol @subprotocol end |
Class Method Details
.from_hash(data) ⇒ Object
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 |
# File 'lib/mockserver/models.rb', line 1134 def self.from_hash(data) return nil if data.nil? = data['messages'] = &.map { |m| WebSocketMessage.from_hash(m) } new( subprotocol: data['subprotocol'], messages: , close_connection: data['closeConnection'], delay: Delay.from_hash(data['delay']), primary: data['primary'] ) end |
Instance Method Details
#to_h ⇒ Object
1124 1125 1126 1127 1128 1129 1130 1131 1132 |
# File 'lib/mockserver/models.rb', line 1124 def to_h result = {} result['subprotocol'] = @subprotocol unless @subprotocol.nil? result['messages'] = @messages&.map(&:to_h) if @messages result['closeConnection'] = @close_connection unless @close_connection.nil? result['delay'] = @delay.to_h if @delay result['primary'] = @primary unless @primary.nil? result end |