Skip to content

Commit

Permalink
Ruby 1.9.2: work around Array allowing method_missing for to_ary
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Nov 13, 2009
1 parent c0ebc21 commit f07bcf0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions activesupport/lib/active_support/core_ext/array/wrap.rb
Expand Up @@ -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

0 comments on commit f07bcf0

Please sign in to comment.