lib/sinatra/compat.rb in bmizerany-sinatra-0.9.0.2 vs lib/sinatra/compat.rb in bmizerany-sinatra-0.9.0.4

- old
+ new

@@ -49,10 +49,21 @@ 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 def initialize(*args, &block) sinatra_warn 'Sinatra::ServerError is deprecated;', @@ -91,24 +102,13 @@ def entity_tag(*args, &block) sinatra_warn "The 'entity_tag' method is deprecated; use 'etag' instead." etag(*args, &block) end - # The :disposition option is deprecated; use: #attachment. This method - # setting the Content-Transfer-Encoding header is deprecated. - #-- - # TODO deprecation warning for :disposition argument. - def send_file(path, opts={}) - opts[:disposition] = 'attachment' if !opts.key?(:disposition) - attachment opts[:filename] || path if opts[:filename] || opts[:disposition] - response['Content-Transfer-Encoding'] = 'binary' if opts[:disposition] - super(path, opts) - end - # Throwing halt with a Symbol and the to_result convention are # deprecated. Override the invoke method to detect those types of return # values. - def invoke(handler) + def invoke(&block) res = super case when res.kind_of?(Symbol) sinatra_warn "Invoking the :#{res} helper by returning a Symbol is deprecated;", "call the helper directly instead."