UnionType

reactivemongo.api.bson.MacroOptions$.UnionType
trait UnionType[Types <: \/ ] extends Default

This allows to restrict the handling of family to only some subtypes (not required to be sealed in this case).

import reactivemongo.api.bson.{
 BSONDocumentWriter, Macros, MacroOptions
}, MacroOptions.\/

trait Family
case class TypeA(n: Int) extends Family
case class TypeB(s: String) extends Family
case class TypeC(f: Float) extends Family

val writer: BSONDocumentWriter[Family] = {
 implicit val a = Macros.writer[TypeA]
 implicit val b = Macros.writer[TypeB]

 Macros.using[MacroOptions.UnionType[TypeA \/ TypeB]].writer[Family]
}

Attributes

Types

to restrict the subtypes to handle

See also:

/

Graph
Supertypes
trait Default
class Object
trait Matchable
class Any

Members list

Concise view