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