diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-10-28 06:51:25 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-10-28 06:51:25 -0700 |
commit | f51ac9e78014b6be531b4413de79fb041721df11 (patch) | |
tree | c4885a030768cd40bed063f5106bd6d042a8dec0 /activesupport | |
parent | c9487ed6aff76693f33ff89e466ba944297681d3 (diff) | |
download | rails-f51ac9e78014b6be531b4413de79fb041721df11.tar.gz rails-f51ac9e78014b6be531b4413de79fb041721df11.tar.bz2 rails-f51ac9e78014b6be531b4413de79fb041721df11.zip |
Array.wrap(struct) needs to return the wrapped struct
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/wrap.rb | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/wrap.rb b/activesupport/lib/active_support/core_ext/array/wrap.rb index 63b6640843..38bb68c1ec 100644 --- a/activesupport/lib/active_support/core_ext/array/wrap.rb +++ b/activesupport/lib/active_support/core_ext/array/wrap.rb @@ -1,19 +1,14 @@ 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. - array = Array("foo\nbar") - - if array.size == 1 - def self.wrap(object) + def self.wrap(object) + if object.nil? + [] + # to_a doesn't work correctly with Array() but to_ary always does + elsif object.respond_to?(:to_a) && !object.respond_to?(:to_ary) + [object] + else Array(object) end - else - def self.wrap(object) - if object.is_a?(String) - [object] - else - Array(object) - end - end end end |