module AnyCable::Rails::Connections::SerializableIdentification

def fetch_identifier(name)

Fetch identifier and deserialize if neccessary
def fetch_identifier(name)
  return unless @cached_ids
  @cached_ids[name] ||= @cached_ids.fetch(name) do
    AnyCable::Rails.deserialize(@serialized_ids[name.to_s])
  end
end

def identified_by(*identifiers)

def identified_by(*identifiers)
  super
  Array(identifiers).each do |identifier|
    define_method(identifier) do
      instance_variable_get(:"@#{identifier}") || fetch_identifier(identifier)
    end
  end
end

def identifiers_hash

Converts GlobalID compatible vars to corresponding global IDs params.
Generate identifiers info.
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

def identifiers_json

def identifiers_json
  identifiers_hash.to_json
end