summary refs log tree commit
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2016-05-04 12:22:27 -0500
committerAaron Patterson <aaron.patterson@gmail.com>2016-05-04 12:22:27 -0500
commite8bf33a559a0343adf716e4ded7ef84c03a7a6a3 (patch)
tree012675e143a5c528b889aea0c071a022909ba6ee
parentbc279cf22f0ef3a21f95825cc6a83c7f7d766dcc (diff)
parent7c3d700c00d13e0dead8f110a95606fd1332c5a2 (diff)
downloadrack-e8bf33a559a0343adf716e4ded7ef84c03a7a6a3.tar.gz
Merge pull request #1069 from sgrif/sg-deprecate-params-accessors
Move `Request#[]` and `Request#[]=` to `Helpers` and deprecate them
-rw-r--r--lib/rack/request.rb32
1 files changed, 20 insertions, 12 deletions
diff --git a/lib/rack/request.rb b/lib/rack/request.rb
index a76f15cd..0a64f69e 100644
--- a/lib/rack/request.rb
+++ b/lib/rack/request.rb
@@ -16,18 +16,6 @@ module Rack
       super(env)
     end
 
-    # shortcut for <tt>request.params[key]</tt>
-    def [](key)
-      params[key.to_s]
-    end
-
-    # shortcut for <tt>request.params[key] = value</tt>
-    #
-    # Note that modifications will not be persisted in the env. Use update_param or delete_param if you want to destructively modify params.
-    def []=(key, value)
-      params[key.to_s] = value
-    end
-
     # like Hash#values_at
     def values_at(*keys)
       keys.map{|key| params[key] }
@@ -437,6 +425,26 @@ module Rack
         ip =~ /\A127\.0\.0\.1\Z|\A(10|172\.(1[6-9]|2[0-9]|30|31)|192\.168)\.|\A::1\Z|\Afd[0-9a-f]{2}:.+|\Alocalhost\Z|\Aunix\Z|\Aunix:/i
       end
 
+      # shortcut for <tt>request.params[key]</tt>
+      def [](key)
+        if $verbose
+          warn("Request#[] is deprecated and will be removed in a future version of Rack. Please use request.params[] instead")
+        end
+
+        params[key.to_s]
+      end
+
+      # shortcut for <tt>request.params[key] = value</tt>
+      #
+      # Note that modifications will not be persisted in the env. Use update_param or delete_param if you want to destructively modify params.
+      def []=(key, value)
+        if $verbose
+          warn("Request#[]= is deprecated and will be removed in a future version of Rack. Please use request.params[]= instead")
+        end
+
+        params[key.to_s] = value
+      end
+
       private
 
       def default_session; {}; end