Skip to content

Commit

Permalink
Add deprecated Sinatra::EventContext to unbreak plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomayko committed Jan 25, 2009
1 parent b2324b1 commit b709c8a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions compat/compat_test.rb
@@ -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
11 changes: 11 additions & 0 deletions lib/sinatra/compat.rb
Expand Up @@ -51,6 +51,17 @@ module Sinatra
module Compat module Compat
end 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 # The ServerError exception is deprecated. Any exception is considered an
# internal server error. # internal server error.
class ServerError < RuntimeError class ServerError < RuntimeError
Expand Down

0 comments on commit b709c8a

Please sign in to comment.