Ruby 1.9.2: work around Array allowing method_missing for to_ary

This commit is contained in:
Jeremy Kemper
2009-11-12 16:31:23 -08:00
parent c0ebc21493
commit f07bcf015e

View File

@@ -4,11 +4,10 @@ class Array
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]
elsif object.respond_to?(:to_ary)
object.to_ary
else
Array(object)
[object]
end
end
end