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

play.api.rest.Res.scala Maven / Gradle / Ivy

package play.api.rest

/**
 * @author Karel Cemus
 */
class Res[T](val id: Long, handler: ResourceHandler[T, _]) {

  private var _value: Option[Either[Error, T]] = None

  def value(implicit context: Context): Either[Error, T] = _value match {
    case Some(value) => value
    case _ =>
      val loaded = handler.load(id)
      _value = Some(loaded)
      loaded
  }

  def get: Either[Error, T] = _value.get
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy