Skip to content

Commit 3fb680a

Browse files
committed
Remove code duplication by moving logic to check_if_method_has_arguments!
1 parent 773eeec commit 3fb680a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

activerecord/lib/active_record/relation/query_methods.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,8 +1606,6 @@ def sanitize_order_arguments(order_args)
16061606
order_args.map! do |arg|
16071607
klass.sanitize_sql_for_order(arg)
16081608
end
1609-
order_args.flatten!
1610-
order_args.compact_blank!
16111609
end
16121610

16131611
def column_references(order_args)
@@ -1676,9 +1674,9 @@ def resolve_arel_attributes(attrs)
16761674
def check_if_method_has_arguments!(method_name, args, message = nil)
16771675
if args.blank?
16781676
raise ArgumentError, message || "The method .#{method_name}() must contain arguments."
1679-
elsif block_given?
1680-
yield args
16811677
else
1678+
yield args if block_given?
1679+
16821680
args.flatten!
16831681
args.compact_blank!
16841682
end

0 commit comments

Comments
 (0)