aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/OutputHelpers.scala
blob: 3a184a4897ceb287e27e08ff40ead4242ffbaf6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
trait OutputHelpers extends slick.codegen.OutputHelpers {

  def imports: String

  def headerComment: String = ""

  override def packageCode(profile: String,
                           pkg: String,
                           container: String,
                           parentType: Option[String]): String = {
    s"""|${headerComment.trim().lines.map("// " + _).mkString("\n")}
        |package $pkg
        |
        |$imports
        |
        |/** Stand-alone Slick data model for immediate use */
        |package object $container extends {
        |  val profile = $profile
        |} with Tables
        |
        |/** Slick data model trait for extension, choice of backend or usage in the cake pattern. (Make sure to initialize this late.) */
        |trait Tables${parentType.fold("")(" extends " + _)} {
        |  import profile.api._
        |  ${indent(code)}
        |}""".stripMargin.trim()
  }
}