Created
November 4, 2011 03:40
-
-
Save ox/1338607 to your computer and use it in GitHub Desktop.
A minimal layout and explanation of Sinatra inner workings, regarding compactness, and hooking.
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
module Aleph | |
class Application | |
def self.run! | |
puts "hello world" | |
end | |
end | |
# here is where the trick with sinatra is! | |
# all of your path defenitions and such have built up a hash | |
# of routes. When ruby reaches EOF in your script, it calls this | |
# little line right here, which will run the class method run! | |
# up there. It's a clever hook. Makes for easy... hooking? | |
at_exit { Application.run! } | |
end | |
# including Aleph executes the 'at_exit {}' line | |
include Aleph |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment