From 62ddeaf0522a00d1040d19d616238fa47177ba64 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 9 Dec 2007 23:02:50 +0000 Subject: Missed commit. References #10395. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8344 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_support/core_ext/object/conversions.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 activesupport/lib/active_support/core_ext/object/conversions.rb (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/object/conversions.rb b/activesupport/lib/active_support/core_ext/object/conversions.rb new file mode 100644 index 0000000000..ad752f0fc5 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/object/conversions.rb @@ -0,0 +1,14 @@ +class Object + # Alias of to_s. + def to_param + to_s + end + + # Converts an object into a string suitable for use as a URL query string, using the given key 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) + "#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}" + end +end \ No newline at end of file -- cgit v1.2.3