lib/ripple/embedded_document.rb in ripple-1.0.0.beta vs lib/ripple/embedded_document.rb in ripple-1.0.0.beta2
- old
+ new
@@ -26,10 +26,11 @@
included do
extend ActiveModel::Naming
include Persistence
extend Ripple::Properties
include Ripple::AttributeMethods
+ include Ripple::Indexes
include Ripple::Timestamps
include Ripple::Validations
include Ripple::Associations
include Ripple::Callbacks
include Ripple::EmbeddedDocument::AroundCallbacks
@@ -44,21 +45,19 @@
def embeddable?
true
end
end
- module InstanceMethods
- def ==(other)
- self.class == other.class &&
+ def ==(other)
+ self.class == other.class &&
_parent_document == other._parent_document &&
serializable_hash == other.serializable_hash
- end
- alias eql? ==
+ end
+ alias eql? ==
- def hash
- parent = [_parent_document.class]
- parent << [_parent_document.key] if _parent_document.respond_to?(:key)
- [ self.class, parent, serializable_hash ].hash
- end
+ def hash
+ hash = self.class.hash ^ _parent_document.class.hash ^ serializable_hash.to_s.hash
+ hash ^= _parent_document.key.hash if _parent_document.respond_to?(:key)
+ hash
end
end
end