Permalink
Browse files

add deprecation warning for Sinatra::Default

  • Loading branch information...
rtomayko committed Mar 4, 2010
1 parent 7a74c72 commit 9cf0c0d59417ed37c9bbc410236a50826fc1fe76
Showing with 19 additions and 8 deletions.
  1. +1 −1 compat/compat_test.rb
  2. +15 −4 lib/sinatra/base.rb
  3. +3 −3 lib/sinatra/compat.rb
View
@@ -7,6 +7,6 @@
end
specify "makes EventContext available" do
- assert_same Sinatra::Default, Sinatra::EventContext
+ assert_same Sinatra::Application, Sinatra::EventContext
end
end
View
@@ -1080,9 +1080,9 @@ class << self
end
end
- # The top-level Application. All DSL methods executed on main are delegated
- # to this class.
- class Application < Base
+ # Deprecated as base class for non-top-level apps. Subclass
+ # Sinatra::Base instead and set options as needed.
+ class Default < Base
set :raise_errors, Proc.new { test? }
set :show_exceptions, Proc.new { development? }
set :dump_errors, true
@@ -1097,9 +1097,20 @@ def self.register(*extensions, &block) #:nodoc:
Delegator.delegate(*added_methods)
super(*extensions, &block)
end
+
+ def self.inherited(subclass)
+ if subclass.to_s != 'Sinatra::Application'
+ sinatra_warn 'Sinatra::Default is deprecated;' +
+ ' subclass Sinatra::Base instead'
+ end
+ super
+ end
end
- Default = Application
+ # The top-level Application. All DSL methods executed on main are delegated
+ # to this class.
+ class Application < Default
+ end
# Sinatra delegation mixin. Mixing this module into an object causes all
# methods to be delegated to the Sinatra::Application class. Used primarily
View
@@ -48,9 +48,9 @@ module Compat #:nodoc:
# Make Sinatra::EventContext an alias for Sinatra::Default to unbreak plugins.
def self.const_missing(const_name) #:nodoc:
if const_name == :EventContext
- const_set :EventContext, Sinatra::Default
- sinatra_warn 'Sinatra::EventContext is deprecated; use Sinatra::Default instead.'
- Sinatra::Default
+ const_set :EventContext, Sinatra::Application
+ sinatra_warn 'Sinatra::EventContext is deprecated; use Sinatra::Application instead.'
+ Sinatra::Application
else
super
end

0 comments on commit 9cf0c0d

Please sign in to comment.