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.
1164 1165 1166 1167 1168 1169 1170 |
# File 'lib/mockserver/models.rb', line 1164 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.
1162 1163 1164 |
# File 'lib/mockserver/models.rb', line 1162 def close_connection @close_connection end |
#delay ⇒ Object
Returns the value of attribute delay.
1162 1163 1164 |
# File 'lib/mockserver/models.rb', line 1162 def delay @delay end |
#messages ⇒ Object
Returns the value of attribute messages.
1162 1163 1164 |
# File 'lib/mockserver/models.rb', line 1162 def @messages end |
#primary ⇒ Object
Returns the value of attribute primary.
1162 1163 1164 |
# File 'lib/mockserver/models.rb', line 1162 def primary @primary end |
#subprotocol ⇒ Object
Returns the value of attribute subprotocol.
1162 1163 1164 |
# File 'lib/mockserver/models.rb', line 1162 def subprotocol @subprotocol end |
Class Method Details
.from_hash(data) ⇒ Object
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 |
# File 'lib/mockserver/models.rb', line 1182 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
1172 1173 1174 1175 1176 1177 1178 1179 1180 |
# File 'lib/mockserver/models.rb', line 1172 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 |