routesがシンプルなところ。

# routes.rb:
require 'rubygems'
require 'sinatra'
require 'pp'

get('/foo')  {}
post('/foo') {}
get('/bar')  {}
post('/bar') {}

pp Sinatra::Application.routes

exit
% ruby routes.rb 
{"GET"=>
  [[/^\/foo$/,
    [],
    [],
    #<Proc:0x000001009c5a58@/Users/komagata/.rvm/gems/ruby-1.9.2-p290@default/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212>],
   [/^\/bar$/,
    [],
    [],
    #<Proc:0x0000010159c318@/Users/komagata/.rvm/gems/ruby-1.9.2-p290@default/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212>]],
 "HEAD"=>
  [[/^\/foo$/,
    [],
    [],
    #<Proc:0x0000010159cd90@/Users/komagata/.rvm/gems/ruby-1.9.2-p290@default/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212>],
   [/^\/bar$/,
    [],
    [],
    #<Proc:0x0000010159bee0@/Users/komagata/.rvm/gems/ruby-1.9.2-p290@default/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212>]],
 "POST"=>
  [[/^\/foo$/,
    [],
    [],
    #<Proc:0x0000010159c868@/Users/komagata/.rvm/gems/ruby-1.9.2-p290@default/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212>],
   [/^\/bar$/,
    [],
    [],
    #<Proc:0x0000010159ba08@/Users/komagata/.rvm/gems/ruby-1.9.2-p290@default/gems/sinatra-1.3.1/lib/sinatra/base.rb:1212>]]}

Hash, Array, Regex, Procの組み合わせに過ぎない。自由度MAX。

これはセクシーだ。

Comments


Option