Skip to content

Commit

Permalink
remove code (#2414)
Browse files Browse the repository at this point in the history
* remove code

* fix

* fmt
  • Loading branch information
TomTriple authored Aug 30, 2023
1 parent 23f04fd commit a31493e
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions zio-http/src/main/scala/zio/http/template/IsAttributeValue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,21 @@ import scala.language.implicitConversions
* Checks if the value A can be represented as a valid html attribute.
*/
sealed trait IsAttributeValue[-A] {
implicit def apply(a: A): String
def apply(a: A): String
}

object IsAttributeValue {
implicit def fromString: IsAttributeValue[String] = new IsAttributeValue[String] {
implicit val instanceString: IsAttributeValue[String] = new IsAttributeValue[String] {
override def apply(a: String): String = a
}

implicit def fromInt: IsAttributeValue[Int] = new IsAttributeValue[Int] {
override def apply(a: Int): String = a.toString
}

implicit def fromList: IsAttributeValue[Seq[String]] = new IsAttributeValue[Seq[String]] {
implicit val instanceList: IsAttributeValue[Seq[String]] = new IsAttributeValue[Seq[String]] {
override def apply(a: Seq[String]): String = a.mkString(" ")
}

implicit def fromTuple2Seq: IsAttributeValue[Seq[(String, String)]] = new IsAttributeValue[Seq[(String, String)]] {
override def apply(a: Seq[(String, String)]): String =
a.map { case (k, v) => s"""${k}:${v}""" }.mkString(";")
}
implicit val instanceTuple2Seq: IsAttributeValue[Seq[(String, String)]] =
new IsAttributeValue[Seq[(String, String)]] {
override def apply(a: Seq[(String, String)]): String =
a.map { case (k, v) => s"""${k}:${v}""" }.mkString(";")
}
}

0 comments on commit a31493e

Please sign in to comment.