syntax

meteor.syntax
See thesyntax companion object
trait syntax

Utility to help writing meteor.codec.Codec, meteor.codec.Encoder and meteor.codec.Decoder.

Examples:

import meteor.syntax._
import meteor.codec._

case class Author(
 names: String,
 age: Int
)

case class Book(
 name: String,
 author: Author,
 coAuthor: Option[Author]
)

implicit val encoderForAuthor: Encoder[Author] = Encoder.instance { obj =>
 Map(
   "names" -> obj.names.asAttributeValue,
   "age" -> obj.age.asAttributeValue
 ).asAttributeValue
}

implicit val encoderForBook: Encoder[Book] = Encoder.instance { obj =>
 Map(
   "name" -> obj.names.asAttributeValue,
   "author" -> obj.age.asAttributeValue,
   "coAuthor" -> obj.age.asAttributeValue,
 ).asAttributeValue
}

implicit val decoderForAuthor: Decoder[Author] = Decoder.instance { av =>
 for {
   names <- av.getAs[String]("names")
   age <- av.getAs[Int]("age")
 } yield Author(names, age)
}

implicit val decoderForBook: Decoder[Book] = Decoder.instance { av =>
 for {
   name <- av.getAs[String]("name")
   author <- av.getAs[Author]("author")
   coAuthor <- av.getOpt[Author]("coAuthor")
 } yield Book(name, author, coAuthor)
}

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object syntax

Members list

Type members

Classlikes

implicit class RichReadAttributeValue(av: AttributeValue)

Provide extension method(s) to read from a Java AttributeValue

Provide extension method(s) to read from a Java AttributeValue

Attributes

Supertypes
class Object
trait Matchable
class Any
implicit class RichWriteAttributeValue[A](a: A)(implicit evidence$1: Encoder[A])

Provide extension method(s) to write to a Java AttributeValue

Provide extension method(s) to write to a Java AttributeValue

Attributes

Supertypes
class Object
trait Matchable
class Any

Implicits

Implicits

final implicit def RichReadAttributeValue(av: AttributeValue): RichReadAttributeValue

Provide extension method(s) to read from a Java AttributeValue

Provide extension method(s) to read from a Java AttributeValue

Attributes

final implicit def RichWriteAttributeValue[A : Encoder](a: A): RichWriteAttributeValue[A]

Provide extension method(s) to write to a Java AttributeValue

Provide extension method(s) to write to a Java AttributeValue

Attributes