mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

Set#merge is supposed to return self, and Formula#recursive_requirements depended on this being true. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
26 lines
538 B
Ruby
26 lines
538 B
Ruby
require 'set'
|
|
|
|
class ComparableSet < Set
|
|
def add new
|
|
# smileys only
|
|
return super new unless new.respond_to? :>
|
|
|
|
objs = find_all { |o| o.class == new.class }
|
|
objs.each do |o|
|
|
return self if o > new
|
|
delete o
|
|
end
|
|
super new
|
|
end
|
|
|
|
alias_method :<<, :add
|
|
|
|
# Set#merge bypasses enumerating the set's contents,
|
|
# so the subclassed #add would never be called
|
|
def merge enum
|
|
enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
|
|
enum.each { |o| add(o) }
|
|
self
|
|
end
|
|
end
|