Browse files

Lazy-require CGI for Object#to_query

  • Loading branch information...
1 parent ad93212 commit 27dbc27c4174974a318145d2dc6512457ea37241 @jeremy jeremy committed Nov 26, 2008
Showing with 1 addition and 2 deletions.
  1. +1 −2 activesupport/lib/active_support/core_ext/object/conversions.rb
View
3 activesupport/lib/active_support/core_ext/object/conversions.rb
@@ -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

0 comments on commit 27dbc27

Please sign in to comment.