Add deprecated Sinatra::EventContext to unbreak plugins
This commit is contained in:
parent
8dbd919f45
commit
90581dccb7
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue