Permalink
Browse files

Define case equality for documents.

This should be redefined in classes and not proxies if we want it to
behave correctly.
  • Loading branch information...
1 parent 7ea1e06 commit bfc9a72dbcb3b1b57112b0fc999cc28fe2f94ed2 @arthuraa arthuraa committed with bkeepers May 13, 2011
Showing with 7 additions and 6 deletions.
  1. +0 −5 lib/mongo_mapper/plugins/associations/proxy.rb
  2. +7 −1 lib/mongo_mapper/plugins/equality.rb
@@ -98,11 +98,6 @@ def send(method, *args)
end
end
- def ===(other)
- load_target
- other === target
- end
-
protected
def method_missing(method, *args, &block)
if load_target
@@ -4,6 +4,12 @@ module Plugins
module Equality
extend ActiveSupport::Concern
+ module ClassMethods
+ def ===(other)
+ other.is_a?(self)
+ end
+ end
+
module InstanceMethods
def eql?(other)
other.is_a?(self.class) && _id == other._id
@@ -16,4 +22,4 @@ def hash
end
end
end
-end
+end

0 comments on commit bfc9a72

Please sign in to comment.