This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// kinja-service library | |
trait SsoServiceComponent extends ServiceComponent { | |
val ssoService: SsoService | |
class SsoService extends Service { | |
def authorByToken(token: String): Author = { | |
lookupAuthorInDatabase(token) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// kinja-service library | |
class SsoService extends ApiService { | |
def authorByToken(token: String): Author = { | |
lookupAuthorInDatabase(token) | |
} | |
} | |
case class AuthorByToken(token: String) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// kinja-service library | |
class SsoService extends ApiService { | |
def authorByToken(token: String): Author = { | |
lookupAuthorInDatabase(token) | |
} | |
} | |
trait SsoServiceContract { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// kinja-service library | |
trait AdressBook { | |
val ssoActorPath: String | |
val inviteActorPath: String | |
} | |
class SsoService extends ApiService { | |
self: AddressBook => | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(_)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kinja.foo | |
package bar |