Permalink
Browse files

Do not check defined?(CGI) on every call #to_query

  • Loading branch information...
1 parent c6c1642 commit f1798951e747da23bd1f30a7f1a6c041a117bd8a @printercu printercu committed May 13, 2014
Showing with 1 addition and 1 deletion.
  1. +1 −1 activesupport/lib/active_support/core_ext/object/to_query.rb
@@ -1,12 +1,12 @@
require 'active_support/core_ext/object/to_param'
+require 'cgi'
class Object
# Converts an object into a string suitable for use as a URL query string, using the given <tt>key</tt> as the
# param name.
#
# 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_param)}=#{CGI.escape(to_param.to_s)}"
end
end

0 comments on commit f179895

Please sign in to comment.