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.
1228 1229 1230 1231 1232 1233 1234 |
# File 'lib/mockserver/models.rb', line 1228 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.
1226 1227 1228 |
# File 'lib/mockserver/models.rb', line 1226 def close_connection @close_connection end |
#delay ⇒ Object
Returns the value of attribute delay.
1226 1227 1228 |
# File 'lib/mockserver/models.rb', line 1226 def delay @delay end |
#messages ⇒ Object
Returns the value of attribute messages.
1226 1227 1228 |
# File 'lib/mockserver/models.rb', line 1226 def @messages end |
#primary ⇒ Object
Returns the value of attribute primary.
1226 1227 1228 |
# File 'lib/mockserver/models.rb', line 1226 def primary @primary end |
#subprotocol ⇒ Object
Returns the value of attribute subprotocol.
1226 1227 1228 |
# File 'lib/mockserver/models.rb', line 1226 def subprotocol @subprotocol end |
Class Method Details
.from_hash(data) ⇒ Object
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 |
# File 'lib/mockserver/models.rb', line 1246 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
1236 1237 1238 1239 1240 1241 1242 1243 1244 |
# File 'lib/mockserver/models.rb', line 1236 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 |