Skip to content

Instantly share code, notes, and snippets.

@kiris
Last active August 29, 2015 13:56
Show Gist options
  • Save kiris/9131119 to your computer and use it in GitHub Desktop.
Save kiris/9131119 to your computer and use it in GitHub Desktop.
trait FindTaskContext {
def order:String
def page:Int
def limit:Int
}
class TaskController {
def findTask(code:String, name:String, order:String, limit:Int, page:Int): List[Task] = {
// 実際はDBの接続先情報とかも必要なのでもっと複雑になると思う
object Context extends FindTaskContext {
val order = order
val page = page
val limit = limit
}
TaskService.findTask(code, name, Context)
}
}
object TaskService {
val taskRepository = new TaskRepository() // 実際はDIされる
def findTask(code:String, name:String, ctx:FindTaskContext):List[Task] = {
taskRepository.findCodeAndName(code, name, ctx)
}
}
class TaskRepository {
def findCodeAndName(code:String, name:String, ctx:FindTaskContext):List[Task] = {
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment