All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hyperscala.web.cookie.Cookies.scala Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package org.hyperscala.web.cookie

import org.hyperscala.web.site.WebContext

/**
 * @author Matt Hicks 
 */
case class Cookies(cookies: Map[String, Cookie], original: Map[String, Cookie]) {
  def apply(name: String) = cookies(name)
  def get(name: String) = cookies.get(name)
  def getOrElse(name: String, default: => Cookie) = cookies.getOrElse(name, default)
  def apply(cookie: Cookie) = {
    val updated = cookies + (cookie.name -> cookie)
    WebContext.cookies := copy(cookies = updated)
    updated
  }
  def modified = cookies.collect {
    case (name, cookie) if (isModified(cookie)) => cookie
  }
  def isModified(cookie: Cookie) = cookie != original.getOrElse(cookie.name, null)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy