Add send_data back in but deprecate [#143]

This commit is contained in:
Ryan Tomayko 2009-02-21 23:26:55 -08:00
parent 090c4d79c8
commit a9e9f00240
3 changed files with 14 additions and 1 deletions

View File

@ -20,6 +20,8 @@
* Fix that ERB templates were evaluated twice per "erb" call.
* The ERB output buffer is now available to helpers via the @_out_buf
instance variable.
* The request-level #send_data method from Sinatra 0.3.3 has been added
for compatibility but is deprecated.
= 0.9.0.4 / 2009-01-25

View File

@ -93,7 +93,7 @@ context "SendData" do
end
# Deprecated. send_data is going away.
xspecify "should send the data with options" do
specify "should send the data with options" do
get '/' do
send_data 'asdf', :status => 500
end

View File

@ -106,6 +106,17 @@ module Sinatra
etag(*args, &block)
end
# Deprecated. Use the #attachment helper and return the data as a String or
# Array.
def send_data(data, options={})
sinatra_warn "The 'send_data' method is deprecated. use attachment, status, content_type, etc. helpers instead."
status options[:status] if options[:status]
attachment options[:filename] if options[:disposition] == 'attachment'
content_type options[:type] if options[:type]
halt data
end
# Throwing halt with a Symbol and the to_result convention are
# deprecated. Override the invoke method to detect those types of return
# values.