alias :without :excluding

Delegation by splat arguments will allocates an extra array.
This commit is contained in:
Ryuta Kamizono 2021-02-17 15:36:01 +09:00
parent c6f0861515
commit d049839e1f
3 changed files with 3 additions and 15 deletions

View File

@ -1139,11 +1139,7 @@ module ActiveRecord
spawn.excluding!(records)
end
# Alias for #excluding.
def without(*records)
excluding(*records)
end
alias :without :excluding
def excluding!(records) # :nodoc:
predicates = [ predicate_builder[primary_key, records].invert ]

View File

@ -47,11 +47,7 @@ class Array
def excluding(*elements)
self - elements.flatten(1)
end
# Alias for #excluding.
def without(*elements)
excluding(*elements)
end
alias :without :excluding
# Equal to <tt>self[1]</tt>.
#

View File

@ -152,11 +152,7 @@ module Enumerable
elements.flatten!(1)
reject { |element| elements.include?(element) }
end
# Alias for #excluding.
def without(*elements)
excluding(*elements)
end
alias :without :excluding
# Extract the given key from each element in the enumerable.
#