Class: Ably::Models::ConnectionStateChange
- Inherits:
-
Object
- Object
- Ably::Models::ConnectionStateChange
- Includes:
- Ably::Modules::ModelCommon
- Defined in:
- lib/submodules/ably-ruby/lib/ably/models/connection_state_change.rb
Overview
Contains ConnectionState change information emitted by the Realtime::Connection object.
Instance Attribute Summary
Attributes included from Ably::Modules::ModelCommon
Instance Method Summary collapse
-
#current ⇒ Ably::Realtime::Connection::STATE
The new Realtime::Connection::STATE.
-
#event ⇒ Ably::Realtime::Connection::STATE
The event that triggered this Realtime::Connection::EVENT change.
-
#initialize(hash_object) ⇒ ConnectionStateChange
constructor
A new instance of ConnectionStateChange.
-
#previous ⇒ Ably::Realtime::Connection::STATE
The previous Ably::Models::Connection::STATE.
- #protocol_message ⇒ Object
-
#reason ⇒ Ably::Models::ErrorInfo?
An ErrorInfo object containing any information relating to the transition.
-
#retry_in ⇒ Integer
Duration in milliseconds, after which the client retries a connection where applicable.
- #to_s ⇒ Object
Methods included from Ably::Modules::ModelCommon
#==, #[], #as_json, included, #to_json
Methods included from Ably::Modules::MessagePack
Constructor Details
#initialize(hash_object) ⇒ ConnectionStateChange
Returns a new instance of ConnectionStateChange.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/submodules/ably-ruby/lib/ably/models/connection_state_change.rb', line 7 def initialize(hash_object) unless (hash_object.keys - [:current, :previous, :event, :retry_in, :reason, :protocol_message]).empty? raise ArgumentError, 'Invalid attributes, expecting :current, :previous, :event, :retry_in, :reason' end @hash_object = { current: hash_object.fetch(:current), previous: hash_object.fetch(:previous), event: hash_object[:event], retry_in: hash_object[:retry_in], reason: hash_object[:reason], protocol_message: hash_object[:protocol_message] } rescue KeyError => e raise ArgumentError, e end |
Instance Method Details
#current ⇒ Ably::Realtime::Connection::STATE
The new Realtime::Connection::STATE.
30 31 32 |
# File 'lib/submodules/ably-ruby/lib/ably/models/connection_state_change.rb', line 30 def current @hash_object[:current] end |
#event ⇒ Ably::Realtime::Connection::STATE
The event that triggered this Realtime::Connection::EVENT change.
40 41 42 |
# File 'lib/submodules/ably-ruby/lib/ably/models/connection_state_change.rb', line 40 def event @hash_object[:event] end |
#previous ⇒ Ably::Realtime::Connection::STATE
The previous Ably::Models::Connection::STATE. For the Ably::Models::Connection::EVENT UPDATE event, this is equal to the current Ably::Models::Connection::STATE.
51 52 53 |
# File 'lib/submodules/ably-ruby/lib/ably/models/connection_state_change.rb', line 51 def previous @hash_object[:previous] end |
#protocol_message ⇒ Object
75 76 77 |
# File 'lib/submodules/ably-ruby/lib/ably/models/connection_state_change.rb', line 75 def @hash_object[:protocol_message] end |
#reason ⇒ Ably::Models::ErrorInfo?
An ErrorInfo object containing any information relating to the transition.
61 62 63 |
# File 'lib/submodules/ably-ruby/lib/ably/models/connection_state_change.rb', line 61 def reason @hash_object[:reason] end |
#retry_in ⇒ Integer
Duration in milliseconds, after which the client retries a connection where applicable.
71 72 73 |
# File 'lib/submodules/ably-ruby/lib/ably/models/connection_state_change.rb', line 71 def retry_in @hash_object[:retry_in] end |
#to_s ⇒ Object
79 80 81 |
# File 'lib/submodules/ably-ruby/lib/ably/models/connection_state_change.rb', line 79 def to_s "<ConnectionStateChange: current state #{current}, previous state #{previous}>" end |