Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Lazy-require CGI for Object#to_query

  • Loading branch information...
commit 27dbc27c4174974a318145d2dc6512457ea37241 1 parent ad93212
Jeremy Kemper jeremy authored
3  activesupport/lib/active_support/core_ext/object/conversions.rb
View
@@ -1,5 +1,3 @@
-require 'cgi'
-
class Object
# Alias of <tt>to_s</tt>.
def to_param
@@ -11,6 +9,7 @@ def to_param
#
# Note: This method is defined as a default implementation for all Objects for Hash#to_query to work.
def to_query(key)
+ require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
"#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.