Add deprecated Sinatra::EventContext to unbreak plugins

This commit is contained in:
Ryan Tomayko 2009-01-24 20:27:12 -08:00
parent 8dbd919f45
commit 90581dccb7
2 changed files with 23 additions and 0 deletions

12
compat/compat_test.rb Normal file
View File

@ -0,0 +1,12 @@
require File.dirname(__FILE__) + '/helper'
context "Compat" do
setup do
Sinatra.application = nil
@app = Sinatra.application
end
specify "makes EventContext available" do
assert_same Sinatra::Default, Sinatra::EventContext
end
end

View File

@ -51,6 +51,17 @@ module Sinatra
module Compat
end
# Make Sinatra::EventContext an alias for Sinatra::Default to unbreak plugins.
def self.const_missing(const_name)
if const_name == :EventContext
const_set :EventContext, Sinatra::Default
sinatra_warn 'Sinatra::EventContext is deprecated; use Sinatra::Default instead.'
Sinatra::Default
else
super
end
end
# The ServerError exception is deprecated. Any exception is considered an
# internal server error.
class ServerError < RuntimeError