aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/array
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-11-17 22:47:23 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-11-17 22:47:23 +0000
commit5446d5cb05b50a9a3f317ded774be438e0eff909 (patch)
tree6b0b87efe3e95783763208215a3159fb63217a6d /activesupport/lib/active_support/core_ext/array
parent9754debb9a72f9385950e5282f3642b995ab76d8 (diff)
parentf8877d4b2a2a6f68770b376f0b1391a6295f62f2 (diff)
downloadrails-5446d5cb05b50a9a3f317ded774be438e0eff909.tar.gz
rails-5446d5cb05b50a9a3f317ded774be438e0eff909.tar.bz2
rails-5446d5cb05b50a9a3f317ded774be438e0eff909.zip
Merge remote branch 'mainstream/master'
Conflicts: activesupport/lib/active_support/core_ext/hash/conversions.rb
Diffstat (limited to 'activesupport/lib/active_support/core_ext/array')
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb16
-rw-r--r--activesupport/lib/active_support/core_ext/array/wrap.rb13
2 files changed, 4 insertions, 25 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb
index c53cf3f530..db140225e8 100644
--- a/activesupport/lib/active_support/core_ext/array/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -40,22 +40,6 @@ class Array
end
end
-
- # Calls <tt>to_param</tt> on all its elements and joins the result with
- # slashes. This is used by <tt>url_for</tt> in Action Pack.
- def to_param
- collect { |e| e.to_param }.join '/'
- end
-
- # Converts an array into a string suitable for use as a URL query string,
- # using the given +key+ as the param name.
- #
- # ['Rails', 'coding'].to_query('hobbies') # => "hobbies%5B%5D=Rails&hobbies%5B%5D=coding"
- def to_query(key)
- prefix = "#{key}[]"
- collect { |value| value.to_query(prefix) }.join '&'
- end
-
# Converts a collection of elements into a formatted string by calling
# <tt>to_s</tt> on all elements and joining them:
#
diff --git a/activesupport/lib/active_support/core_ext/array/wrap.rb b/activesupport/lib/active_support/core_ext/array/wrap.rb
index 0eb93a0ded..e211bdeeca 100644
--- a/activesupport/lib/active_support/core_ext/array/wrap.rb
+++ b/activesupport/lib/active_support/core_ext/array/wrap.rb
@@ -11,17 +11,12 @@ class Array
# Array("foo\nbar") # => ["foo\n", "bar"], in Ruby 1.8
# Array.wrap("foo\nbar") # => ["foo\nbar"]
def self.wrap(object)
- case object
- when nil
+ if object.nil?
[]
- when self
- object
+ elsif object.respond_to?(:to_ary)
+ object.to_ary
else
- if object.respond_to?(:to_ary)
- object.to_ary
- else
- [object]
- end
+ [object]
end
end
end