diff options
author | Jeremy Kemper <jeremykemper@gmail.com> | 2014-09-06 07:08:10 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremykemper@gmail.com> | 2014-09-06 07:08:10 -0700 |
commit | 8d75aa9cb335e9d012978dfdfd0bfa1bdf989fae (patch) | |
tree | 8f3402884845ba7fe56866578a9d200c3d3d5ee2 /actionpack/lib | |
parent | 381f9931ec533dd9003f6e7224d7461b93f2fb24 (diff) | |
parent | 2a78d6f561e98684a4988cdc616c6096cd4302d1 (diff) | |
download | rails-8d75aa9cb335e9d012978dfdfd0bfa1bdf989fae.tar.gz rails-8d75aa9cb335e9d012978dfdfd0bfa1bdf989fae.tar.bz2 rails-8d75aa9cb335e9d012978dfdfd0bfa1bdf989fae.zip |
Merge pull request #16822 from jeremy/deprecate-problematic-implicit-response-splatting
Deprecate implicit AD::Response splatting and Array conversion
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 15 |
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 # |