add Sinatra.use

This commit is contained in:
Konstantin Haase 2011-03-31 13:06:08 +02:00
parent cbe5d15d42
commit b03ee9f4f7
2 changed files with 12 additions and 0 deletions

View File

@ -1525,4 +1525,9 @@ module Sinatra
def self.helpers(*extensions, &block) def self.helpers(*extensions, &block)
Delegator.target.helpers(*extensions, &block) Delegator.target.helpers(*extensions, &block)
end end
# Use the middleware for classic applications.
def self.use(*args, &block)
Delegator.target.use(*args, &block)
end
end end

View File

@ -100,6 +100,13 @@ class DelegatorTest < Test::Unit::TestCase
assert_equal app.last_call, ["helpers", mixin.to_s ] assert_equal app.last_call, ["helpers", mixin.to_s ]
end end
it "registers helpers with the delegation target" do
app, mixin = mirror, Module.new
Sinatra.use mixin
assert_equal app.last_call, ["use", mixin.to_s ]
end
delegates 'get' delegates 'get'
delegates 'patch' delegates 'patch'
delegates 'put' delegates 'put'