From a0fc92f455e239fd667ed267b76855eaaf190d2c Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Wed, 28 Oct 2009 01:43:33 -0700 Subject: This is all that's needed in 1.8.7+ --- .../lib/active_support/core_ext/array/wrap.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'activesupport/lib/active_support/core_ext/array') 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 -- cgit v1.2.3