Permalink
Browse files

Replace Base#safe_to_array with Array.wrap

  • Loading branch information...
1 parent 0a1ff1a commit 3b8853eda45dfcae2a1e71b890668730e63bed02 @lifo lifo committed Dec 29, 2009
Showing with 2 additions and 14 deletions.
  1. +2 −14 activerecord/lib/active_record/base.rb
@@ -1645,7 +1645,7 @@ def construct_conditions(conditions, scope)
# Merges includes so that the result is a valid +include+
def merge_includes(first, second)
- (safe_to_array(first) + safe_to_array(second)).uniq
+ (Array.wrap(first) + Array.wrap(second)).uniq
end
def merge_joins(*joins)
@@ -1657,7 +1657,7 @@ def merge_joins(*joins)
end
joins.flatten.map{|j| j.strip}.uniq
else
- joins.collect{|j| safe_to_array(j)}.flatten.uniq
+ joins.collect{|j| Array.wrap(j)}.flatten.uniq
end
end
@@ -1674,18 +1674,6 @@ def build_association_joins(joins)
}.join(" ")
end
- # Object#to_a is deprecated, though it does have the desired behavior
- def safe_to_array(o)
- case o
- when NilClass
- []
- when Array
- o
- else
- [o]
- end
- end
-
def array_of_strings?(o)
o.is_a?(Array) && o.all?{|obj| obj.is_a?(String)}
end

0 comments on commit 3b8853e

Please sign in to comment.