Permalink
Browse files

Improving equality comparisons.

  • Loading branch information...
postmodern committed Jun 24, 2011
1 parent d8d8498 commit cbe49d07ca7700646fdcbec11d441b75b84f529f
Showing with 13 additions and 2 deletions.
  1. +13 −2 lib/warnings/warning.rb
View
@@ -88,9 +88,13 @@ def =~(pattern)
#
def ==(other)
(@message == other.message) &&
- (@source_location == other.source_location)
+ (@source_location == other.source_location) &&
+ (@source_method == other.source_method)
end
+ alias equal? ==
+ alias eql? ==
+
#
# Compares the warning to another warning.
#
@@ -101,7 +105,14 @@ def ==(other)
# Specifies whether the two warnings represent the same message.
#
def ===(other)
- !(@message.match(other).nil?)
+ case other
+ when Warning
+ self == other
+ when Regexp, String
+ !(@message.match(other).nil?)
+ else
+ false
+ end
end
#

0 comments on commit cbe49d0

Please sign in to comment.