module ActionCable::Connection::SerializableIdentification

Public Instance Methods

fetch_identifier(name) click to toggle source

Fetch identifier and deserialize if neccessary

# File lib/anycable/rails/actioncable/connection/serializable_identification.rb, line 35
def fetch_identifier(name)
  @cached_ids[name] ||= @cached_ids.fetch(name) do
    AnyCable::Rails.deserialize(ids[name.to_s])
  end
end
identified_by(*identifiers) click to toggle source
Calls superclass method
# File lib/anycable/rails/actioncable/connection/serializable_identification.rb, line 9
def identified_by(*identifiers)
  super
  Array(identifiers).each do |identifier|
    define_method(identifier) do
      instance_variable_get(:"@#{identifier}") || fetch_identifier(identifier)
    end
  end
end
identifiers_hash() click to toggle source

Generate identifiers info. Converts GlobalID compatible vars to corresponding global IDs params.

# File lib/anycable/rails/actioncable/connection/serializable_identification.rb, line 21
def identifiers_hash
  identifiers.each_with_object({}) do |id, acc|
    obj = instance_variable_get("@#{id}")
    next unless obj

    acc[id] = AnyCable::Rails.serialize(obj)
  end.compact
end
identifiers_json() click to toggle source
# File lib/anycable/rails/actioncable/connection/serializable_identification.rb, line 30
def identifiers_json
  identifiers_hash.to_json
end