- Companion:
- class
Type members
Classlikes
Extend this class in the companion object of a type or type tag that you would like to use as a seed.
Extend this class in the companion object of a type or type tag that you would like to use as a seed.
final case class UserId(value: String)
object UserId extends SeededGen.Companion[UserId](SeedExtractor.from(_.value)) {
sealed abstract class Tag extends SeededGen.Tag
}
This will give you a uniform syntax for constructing seeded generators.
val example: UserId.Gen[String] = UserId.gen(implicit userId => Gen.string)
Extend this marker trait with either your seed class or another marker type tag.
Extend this marker trait with either your seed class or another marker type tag.
This is required to avoid defining an implicit conversion on any primitive types (in the case where you decide to use a primitive type seed). See toGen.
- See also:
Companion documentation for an example of how to use this.
Similar to Companion, but used when you don't want to define the Companion#Tag on the companion object of the model that you are using as a seed.
Similar to Companion, but used when you don't want to define the Companion#Tag on the companion object of the model that you are using as a seed.
Instead you can define a separate tag class and use this as the companion object for that tag type.
final case class UserId(value: String)
// in some other part of the code
sealed abstract class UserIdSeeded extends SeededGen.Tag
object UserIdSeeded extends SeededGen.TagCompanion[UserId, UserIdSeeded]
This will give you a uniform syntax for constructing seeded generators.
val example: UserIdSeeded.Gen[String] = UserIdSeeded.gen(implicit userId => Gen.string)
Implicits
Implicits
Implicitly converts a SeededGen into a regular Gen if there is the appropriate implicit seed in scope.
Implicitly converts a SeededGen into a regular Gen if there is the appropriate implicit seed in scope.
This implicit conversion makes it possible to flatMap over SeededGens the same way you do regular Gens, but it introduces the need to tag the seed type to avoid an implicit conversion on primitive types.