Class: Ably::Realtime::RecoveryKeyContext

Inherits:
Object
  • Object
show all
Defined in:
lib/ably/realtime/recovery_key_context.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection_key, msg_serial, channel_serials) ⇒ RecoveryKeyContext

Returns a new instance of RecoveryKeyContext.



11
12
13
14
15
16
17
18
# File 'lib/ably/realtime/recovery_key_context.rb', line 11

def initialize(connection_key, msg_serial, channel_serials)
  @connection_key = connection_key
  @msg_serial = msg_serial
  @channel_serials = channel_serials
  if @channel_serials.nil?
    @channel_serials = {}
  end
end

Instance Attribute Details

#channel_serialsObject (readonly)

Returns the value of attribute channel_serials.



9
10
11
# File 'lib/ably/realtime/recovery_key_context.rb', line 9

def channel_serials
  @channel_serials
end

#connection_keyObject (readonly)

Returns the value of attribute connection_key.



7
8
9
# File 'lib/ably/realtime/recovery_key_context.rb', line 7

def connection_key
  @connection_key
end

#msg_serialObject (readonly)

Returns the value of attribute msg_serial.



8
9
10
# File 'lib/ably/realtime/recovery_key_context.rb', line 8

def msg_serial
  @msg_serial
end

Class Method Details

.from_json(obj, logger = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/ably/realtime/recovery_key_context.rb', line 24

def self.from_json(obj, logger = nil)
  begin
    data = JSON.load obj
    self.new data['connection_key'], data['msg_serial'], data['channel_serials']
  rescue => e
    logger.warn "unable to decode recovery key, found error #{e}" unless logger.nil?
    return nil
  end
end

Instance Method Details

#to_jsonObject



20
21
22
# File 'lib/ably/realtime/recovery_key_context.rb', line 20

def to_json
  { 'connection_key' => @connection_key, 'msg_serial' => @msg_serial, 'channel_serials' => @channel_serials }.to_json
end