diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/array')
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/conversions.rb | 16 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/wrap.rb | 13 |
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 |