YamlConstructor

shampoo.yaml.YamlConstructor
@FunctionalInterface
trait YamlConstructor[T]

Defines YAML constructor.

import scala.language.implicitConversions

import shampoo.yaml.{ *, given }

case class User(id: Int, name: String)

// Define how to construct User from YAML
given YamlConstructor[User] =
  yaml => User(yaml("id"), yaml("name"))

val yaml = Yaml.load("{ id: 1000, name: lupita }")

// Construct and verify
val user = yaml.as[User]
assert(user.id == 1000)
assert(user.name == "lupita")

Attributes

See also
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def construct(node: YamlNode): T

Constructs data.

Constructs data.

Value parameters

node

YAML node

Attributes