Created
March 27, 2010 19:44
-
-
Save kolo/346315 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
require 'rubygems' | |
require 'sinatra' | |
class WelcomeController | |
@@controller = self.new | |
def self.method_missing(name, *args) | |
@@controller.send(name) | |
end | |
def index | |
"WelcomeController#index" | |
end | |
end | |
class Router | |
def self.route(&block) | |
return unless block | |
block.call(Router.new) | |
end | |
def method_missing(name, *args) | |
Kernel.send(:get, "/#{name}") do | |
WelcomeController.index | |
end | |
end | |
end | |
Router::route do |map| | |
map.welcome :controller => :welcome, :action => :index | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment