module Sinatra::Bind
Constants
- VERSION
Public Class Methods
registered(app)
click to toggle source
Sinatra::Bind
enables to define a route by using instance method. In other words, you can define a route without block.
@example
module AwesomeMethods def before_article @ex = params['id'] * "!" end def find_article(id) "Article##{id} #{@ex}" end end class App < Sinatra::Base include AwesomeMethods def index "hello world" end on "/", to: :index on "/articles/:id", to: :before_article, type: :before on "/articles/:id", to: :find_article end
# File lib/sinatra/bind.rb, line 31 def self.registered(app) app.extend ClassMethods end