Skip to content
This repository
Browse code

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
... ... @@ -1,5 +1,3 @@
1   -require 'cgi'
2   -
3 1 class Object
4 2 # Alias of <tt>to_s</tt>.
5 3 def to_param
@@ -11,6 +9,7 @@ def to_param
11 9 #
12 10 # Note: This method is defined as a default implementation for all Objects for Hash#to_query to work.
13 11 def to_query(key)
  12 + require 'cgi' unless defined?(CGI) && defined?(CGI::escape)
14 13 "#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}"
15 14 end
16 15 end

0 comments on commit 27dbc27

Please sign in to comment.
Something went wrong with that request. Please try again.