aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremykemper@gmail.com>2014-09-05 13:33:20 -0700
committerJeremy Kemper <jeremykemper@gmail.com>2014-09-06 07:05:59 -0700
commit2a78d6f561e98684a4988cdc616c6096cd4302d1 (patch)
tree01b6b899ab50311435c762414a8afb7d30673542 /actionpack/lib
parent31bfcdc77ca0d8cec9b5fe513bdc6f05814dd4f1 (diff)
downloadrails-2a78d6f561e98684a4988cdc616c6096cd4302d1.tar.gz
rails-2a78d6f561e98684a4988cdc616c6096cd4302d1.tar.bz2
rails-2a78d6f561e98684a4988cdc616c6096cd4302d1.zip
Deprecate implicit AD::Response splatting and Array conversion
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index 2fab6be1a5..a58e904c11 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -1,4 +1,5 @@
require 'active_support/core_ext/module/attribute_accessors'
+require 'active_support/deprecation'
require 'action_dispatch/http/filter_redirect'
require 'monitor'
@@ -274,12 +275,22 @@ module ActionDispatch # :nodoc:
end
# Turns the Response into a Rack-compatible array of the status, headers,
- # and body.
+ # and body. Allows explict splatting:
+ #
+ # status, headers, body = *response
def to_a
rack_response @status, @header.to_hash
end
alias prepare! to_a
- alias to_ary to_a
+
+ # Be super clear that a response object is not an Array. Defining this
+ # would make implicit splatting work, but it also makes adding responses
+ # as arrays work, and "flattening" responses, cascading to the rack body!
+ # Not sensible behavior.
+ def to_ary
+ ActiveSupport::Deprecation.warn 'ActionDispatch::Response#to_ary no longer performs implicit conversion to an Array. Please use response.to_a instead, or a splat like `status, headers, body = *response`'
+ to_a
+ end
# Returns the response cookies, converted to a Hash of (name => value) pairs
#