Permalink
Browse files

Override Comparable's ==. Fixes #2.

  • Loading branch information...
1 parent 93c0b53 commit 72db19824ec93752e1dcdab822a57a32c43b01be @duelinmarkers committed Mar 16, 2013
Showing with 8 additions and 1 deletion.
  1. +4 −1 lib/renum/enumerated_value.rb
  2. +4 −0 spec/renum_spec.rb
@@ -50,7 +50,7 @@ def initialize name
end
# Returns the fully qualified name of the constant referring to this value.
- # Don't override this if you're using Renum with the constantize_attribute
+ # Don't override this if you're using Renum with the constantize_attribute
# plugin, which relies on this behavior.
def to_s
"#{self.class}::#{name}"
@@ -61,5 +61,8 @@ def <=> other
index <=> other.index
end
+ def == other
+ equal? other
+ end
end
end
View
@@ -43,6 +43,10 @@
it "makes values comparable" do
Color::RED.should < Color::GREEN
end
+
+ it "doesn't let Comparable's == confuse things" do
+ Color[0].should_not == Status[0]
+ end
end
module MyNamespace

0 comments on commit 72db198

Please sign in to comment.