Created
February 14, 2011 14:23
-
-
Save tizoc/825936 to your computer and use it in GitHub Desktop.
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
| # when handling a request on rack, thread_locals[:request] is set | |
| module FrameworkStuff | |
| def request | |
| thread_locals[:request] | |
| end | |
| end |
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
| class Auth | |
| extend FrameworkStuff | |
| include FrameworkStuff | |
| route '/signup/', :signup | |
| route '/logout/', :logout | |
| def signup | |
| if request.post? | |
| # process params | |
| redirect '/home' if validated | |
| end | |
| render 'login.haml' # if it is a get or didn't validate you render the login firm | |
| end | |
| # ... | |
| end |
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
| class Site | |
| extend FrameworkStuff | |
| include FrameworkStuff | |
| route '/', :home | |
| route '/some_subsection/', SomeSubsectionClass # passes this to a SomeSubsectionClass instance | |
| def home | |
| render 'home.haml' | |
| end | |
| end |
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
| class SomeSubsectionClass | |
| extend FrameworkStuff | |
| include FrameworkStuff | |
| route '/', :list | |
| route '/new/', :new | |
| def list | |
| objects = Model.all | |
| render 'list.haml', objects: objects | |
| end | |
| def new | |
| if request.post? | |
| # handle request | |
| redirect :list if validated? | |
| end | |
| renter 'blah.haml' | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment