diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-10-28 01:43:33 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-10-28 01:43:33 -0700 |
commit | a0fc92f455e239fd667ed267b76855eaaf190d2c (patch) | |
tree | 218b0fb12c377e557d77598eadf7d66d676c6ba8 | |
parent | c5e73b897616049c613b0331dd53e88dbc9c1532 (diff) | |
download | rails-a0fc92f455e239fd667ed267b76855eaaf190d2c.tar.gz rails-a0fc92f455e239fd667ed267b76855eaaf190d2c.tar.bz2 rails-a0fc92f455e239fd667ed267b76855eaaf190d2c.zip |
This is all that's needed in 1.8.7+
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/wrap.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/wrap.rb b/activesupport/lib/active_support/core_ext/array/wrap.rb index 9d45c2739b..63b6640843 100644 --- a/activesupport/lib/active_support/core_ext/array/wrap.rb +++ b/activesupport/lib/active_support/core_ext/array/wrap.rb @@ -1,17 +1,18 @@ class Array # Wraps the object in an Array unless it's an Array. Converts the # object to an Array using #to_ary if it implements that. - def self.wrap(object) - case object - when nil - [] - when self - object - else - if object.respond_to?(:to_ary) - object.to_ary - else + array = Array("foo\nbar") + + if array.size == 1 + def self.wrap(object) + Array(object) + end + else + def self.wrap(object) + if object.is_a?(String) [object] + else + Array(object) end end end |