Skip to content

Instantly share code, notes, and snippets.

@ox
Created November 4, 2011 03:40
Show Gist options
  • Save ox/1338607 to your computer and use it in GitHub Desktop.
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.
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