Skip to content

Commit a6debfc

Browse files
committed
Extract compare config in description
1 parent 6d79577 commit a6debfc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/mongo/server/description.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class Description
142142
# Fields to exclude when comparing two descriptions.
143143
#
144144
# @since 2.0.6
145-
EXCLUDE_FOR_COMPARISON = [ LOCAL_TIME, ELECTION_ID ]
145+
EXCLUDE_FOR_COMPARISON = [ LOCAL_TIME, ELECTION_ID ].freeze
146146

147147
# @return [ Address ] address The server's address.
148148
attr_reader :address
@@ -553,11 +553,17 @@ def me_mismatch?
553553
def ==(other)
554554
return false if self.class != other.class
555555
return true if config == other.config
556+
compare_config(other)
557+
end
558+
alias_method :eql?, :==
559+
560+
private
561+
562+
def compare_config(other)
556563
!config.keys.empty? && config.keys.all? do |k|
557564
config[k] == other.config[k] || EXCLUDE_FOR_COMPARISON.include?(k)
558565
end
559566
end
560-
alias_method :eql?, :==
561567
end
562568
end
563569
end

0 commit comments

Comments
 (0)