Skip to content
Browse files

Add deprecated Sinatra::EventContext to unbreak plugins

  • Loading branch information...
1 parent b2324b1 commit b709c8a8703e7818d41fff925410b05cc98fff5c @rtomayko rtomayko committed Jan 24, 2009
Showing with 23 additions and 0 deletions.
  1. +12 −0 compat/compat_test.rb
  2. +11 −0 lib/sinatra/compat.rb
View
12 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
View
11 lib/sinatra/compat.rb
@@ -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

0 comments on commit b709c8a

Please sign in to comment.
Something went wrong with that request. Please try again.