mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
This is all that's needed in 1.8.7+
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user