Skip to content

Commit

Permalink
Make Base.merge_conditions public
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Jun 17, 2008
1 parent d7b3c33 commit e328bda
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -1297,6 +1297,20 @@ def sti_name
store_full_sti_class ? name : name.demodulize
end

# Merges conditions so that the result is a valid +condition+
def merge_conditions(*conditions)
segments = []

conditions.each do |condition|
unless condition.blank?
sql = sanitize_sql(condition)
segments << sql unless sql.blank?
end
end

"(#{segments.join(') AND (')})" unless segments.empty?
end

private
def find_initial(options)
options.update(:limit => 1)
Expand Down Expand Up @@ -1484,20 +1498,6 @@ def merge_includes(first, second)
(safe_to_array(first) + safe_to_array(second)).uniq
end

# Merges conditions so that the result is a valid +condition+
def merge_conditions(*conditions)
segments = []

conditions.each do |condition|
unless condition.blank?
sql = sanitize_sql(condition)
segments << sql unless sql.blank?
end
end

"(#{segments.join(') AND (')})" unless segments.empty?
end

# Object#to_a is deprecated, though it does have the desired behavior
def safe_to_array(o)
case o
Expand Down

0 comments on commit e328bda

Please sign in to comment.