diff options
Diffstat (limited to 'activesupport')
-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 |