module ActionDispatch::Cookies::SerializedCookieJars

def deserialize(name)

def deserialize(name)
  rotate = false
  value  = yield -> { rotate = true }
  if value
    case
    when needs_migration?(value)
      Marshal.load(value).tap do |v|
        self[name] = { value: v }
      end
    when rotate
      serializer.load(value).tap do |v|
        self[name] = { value: v }
      end
    else
      serializer.load(value)
    end
  end
end

def digest

def digest
  request.cookies_digest || "SHA1"
end

def needs_migration?(value)

def needs_migration?(value)
  request.cookies_serializer == :hybrid && value.start_with?(MARSHAL_SIGNATURE)
end

def serialize(value)

def serialize(value)
  serializer.dump(value)
end

def serializer

def serializer
  serializer = request.cookies_serializer || :marshal
  case serializer
  when :marshal
    MarshalWithJsonFallback
  when :json, :hybrid
    JsonSerializer
  else
    serializer
  end
end