class Ably::Models::ChannelStateChange
Contains state change information emitted by {Ably::Rest::Channel} and {Ably::Realtime::Channel} objects.
Public Class Methods
Source
# File lib/ably/models/channel_state_change.rb, line 7 def initialize(hash_object) unless (hash_object.keys - [:current, :previous, :event, :reason, :resumed, :protocol_message]).empty? raise ArgumentError, 'Invalid attributes, expecting :current, :previous, :event, :reason, :resumed' end @hash_object = { current: hash_object.fetch(:current), previous: hash_object.fetch(:previous), event: hash_object[:event], reason: hash_object[:reason], protocol_message: hash_object[:protocol_message], resumed: hash_object[:resumed] } rescue KeyError => e raise ArgumentError, e end
Public Instance Methods
Source
# File lib/ably/models/channel_state_change.rb, line 30 def current @hash_object[:current] end
The new current {Ably::Realtime::Channel::STATE}.
@spec RTL2a, RTL2b
@return [Ably::Realtime::Channel::STATE]
Source
# File lib/ably/models/channel_state_change.rb, line 50 def event @hash_object[:event] end
The event that triggered this {Ably::Realtime::Channel::STATE} change.
@spec TH5
@return [Ably::Realtime::Channel::STATE]
Source
# File lib/ably/models/channel_state_change.rb, line 40 def previous @hash_object[:previous] end
The previous state. For the {Ably::Realtime::Channel::EVENT}(:update) event, this is equal to the current {Ably::Realtime::Channel::STATE}.
@spec RTL2a, RTL2b
@return [Ably::Realtime::Channel::EVENT]
Source
# File lib/ably/models/channel_state_change.rb, line 76 def protocol_message @hash_object[:protocol_message] end
@api private
Source
# File lib/ably/models/channel_state_change.rb, line 60 def reason @hash_object[:reason] end
An {Ably::Models::ErrorInfo} object containing any information relating to the transition.
@spec RTL2e, TH3
@return [Ably::Models::ErrorInfo, nil]
Source
# File lib/ably/models/channel_state_change.rb, line 70 def resumed !!@hash_object[:resumed] end
Indicates whether message continuity on this channel is preserved, see Nonfatal channel errors for more info.
@spec RTL2f, TH4
@return [Boolean]
Source
# File lib/ably/models/channel_state_change.rb, line 80 def to_s "<ChannelStateChange: current state #{current}, previous state #{previous}>" end