Class: ActionCable::SubscriptionAdapter::SubscriberMap::Message

Inherits:
Struct
  • Object
show all
Defined in:
lib/action_cable/subscription_adapter/subscriber_map.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessage

Returns a new instance of Message.



9
10
11
12
# File 'lib/action_cable/subscription_adapter/subscriber_map.rb', line 9

def initialize(...)
  super
  @cache = Concurrent::Map.new
end

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



8
9
10
# File 'lib/action_cable/subscription_adapter/subscriber_map.rb', line 8

def data
  @data
end

Instance Method Details

#encoded_for(identifier) ⇒ Object



14
15
16
17
18
# File 'lib/action_cable/subscription_adapter/subscriber_map.rb', line 14

def encoded_for(identifier)
  @cache.compute_if_absent(identifier) do
    ActiveSupport::JSON.encode({ identifier: identifier, message: ActiveSupport::JSON.decode(data) })
  end
end