Skip to content

Instantly share code, notes, and snippets.

@kolo
Created March 27, 2010 19:44
Show Gist options
  • Save kolo/346315 to your computer and use it in GitHub Desktop.
Save kolo/346315 to your computer and use it in GitHub Desktop.
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