Advertisement
ATuin

Untitled

Jan 11th, 2014
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.49 KB | None | 0 0
  1. trait BlogSystem[A] {
  2.   val postsDirectory: File
  3.   def postFile[A](title: String): Option[File] =
  4.       postsDirectory.some.filter(f => f.isFile && f.canRead)
  5. }
  6.  
  7. object BlogPost {
  8.   def unapply[A](title: String)(implicit ev:BlogSystem[A]): Option[BlogPost] = {
  9.     ev.postFile(title).map(BlogPost(_))
  10.   }
  11. }
  12.  
  13. class BlogPlan[A] extends Plan with Scalate {
  14.   def intent = Intent {
  15.     case Path(Seg("post" :: BlogPost(post) :: Nil)) => Ok ~> ResponseString(post.file.toString)
  16.   }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement