quackingduck / sinatra-scopes

Simple request handler scoping for sinatra

This URL has Read+Write access

name age message
file .gitignore Loading commit data...
file README.md
file Rakefile
file VERSION
file example_app.rb
file examples.rb
directory lib/
README.md

Sinatra Scopes

Simple scoping for your request handlers. From example_app.rb:

scope :project, '/projects/*' do |project_id|
  @project = Project[project_id]
end

project.get '/users/*' do |user_id|
  @user = User[user_id]
  "#{@project}, #{@user}"
end

Scopes don't have to specify a path pattern:

scope(:authorized) { auth }

authorized.get '/sekret/*' do |page|
  page
end

Similar Implementations

dcparker - cilantro/lib/cilantro/controller.rb