-
-
Save lucashungaro/1924445 to your computer and use it in GitHub Desktop.
Some ideas on a small framework. Yet another web framework.
This file contains 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
class Lists < App | |
all { List.all } # :get /lists | |
one { List.find(params[:id]) } # :get /lists/:id | |
instance { List.new(params[:list]) } | |
to_update { list.update_attributes(params[:list]) } | |
to_destroy { list.destroy } | |
# If you want to set an action for this resource only. | |
get :search do | |
List.search(params[:query]) | |
end | |
end | |
class Tasks < App | |
parent List # this invokes List#find and sets an ivar before finding tasks | |
all { list.tasks.all } # :get /lists/:id/tasks | |
one { list.tasks.find(params[:task_id]) } # :get /lists/:id/tasks/:id | |
instance { list.tasks.new(params[:task]) } | |
to_update { task.update_attributes(params[:task]) } | |
to_destroy { task.destroy } | |
end | |
class Search | |
all { SearchService.search(params[:resource], params[:query]) } # :get /search | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment