lib/picky/query/allocations.rb in picky-4.21.2 vs lib/picky/query/allocations.rb in picky-4.22.0
- old
+ new
@@ -51,11 +51,11 @@
# Only those passed in are removed.
#
def remove_categories categories = []
@allocations.each { |allocation| allocation.remove categories } unless categories.empty?
end
-
+
# Removes allocations.
#
# Only those passed in are removed.
#
# TODO Rewrite, speed up.
@@ -68,11 +68,11 @@
allocation_qualifiers == qualifiers
end
allocation
end
end
-
+
# Keeps allocations.
#
# Only those passed in are kept.
#
# TODO Rewrite, speed up.
@@ -88,11 +88,11 @@
end
# Returns the top amount ids.
#
def ids amount = 20
- @allocations.inject([]) do |total, allocation|
+ inject([]) do |total, allocation|
total.size >= amount ? (return total.shift(amount)) : total + allocation.ids
end
end
# This is the main method of this class that will replace ids and count.
@@ -126,10 +126,10 @@
break if terminate_early <= 0
terminate_early -= 1
end
end
end
-
+
# Same as #process! but removes duplicate ids from results.
#
# Note that in the result later on an allocation won't be
# included if it contains no ids (even in case they have been
# eliminated by the unique constraint in this method).
\ No newline at end of file