Skip to content

Instantly share code, notes, and snippets.

// kinja-service library
trait SsoServiceComponent extends ServiceComponent {
val ssoService: SsoService
class SsoService extends Service {
def authorByToken(token: String): Author = {
lookupAuthorInDatabase(token)
}
// kinja-service library
class SsoService extends ApiService {
def authorByToken(token: String): Author = {
lookupAuthorInDatabase(token)
}
}
class InvitesService extends Service {
def invite(token: String, invitee: Author, authorResolver: String => Author): Unit = {
// kinja-service library
class SsoService extends ApiService {
def authorByToken(token: String): Author = {
lookupAuthorInDatabase(token)
}
}
case class AuthorByToken(token: String)
// kinja-service library
class SsoService extends ApiService {
def authorByToken(token: String): Author = {
lookupAuthorInDatabase(token)
}
}
trait SsoServiceContract {
// kinja-service library
trait AdressBook {
val ssoActorPath: String
val inviteActorPath: String
}
class SsoService extends ApiService {
self: AddressBook =>
package org.pblue.treee
case class Node[T](var value: T, var children: List[Node[T]])
trait Treee[T] {
val root: Node[T]
def filter(pred: T => Boolean): List[Node[T]]
case class Node(level: Int, value: String, children: List[Node])
// This returns a pair of lists, which of the first one is the result,
// and given the constraints on the input, must always have only one element.
// The second list must always be empty in the end result.
def build(input: List[(Int, String)]): (List[Node], List[Node]) =
input match {
case Nil => (Nil, Nil)
case (level, value)::Nil => (List(Node(level, value, List())), Nil)
case (level, value)::tail =>
case class PermalinkPageData(
post: Post,
comments: ReplyList,
sidebar: Sidebar)
class PermalinkPageDataSoy extends SoyWrites[PermalinkPageData] {
def toSoy: Future[SoyMap] = Soy.future {
"post" -> post.toSoy,
"comments" -> comments.toSoy,
"sidebar" -> sidebar.render.map(SoyString(_))
@privateblue
privateblue / page fragments 2.scala
Last active August 29, 2015 14:00
this is basically pseudo-code
trait SectionData
object Render {
def map(items: (String, Future[SoyValue])*): Seq[(String, Future[SoyValue])] = items
}
implicit class Renderable[T : Renderer[T]](data: T) {
def soy(template: String): Future[SoyValue] = implicitly[Renderer[T]].soy(template, data)
def html(template: String): Future[String] = implicitly[Renderer[T]].html(template, data)
}
package com.kinja.foo
package bar