lib/ripple/embedded_document.rb in ripple-0.9.5 vs lib/ripple/embedded_document.rb in ripple-1.0.0.beta
- old
+ new
@@ -1,22 +1,9 @@
-# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
require 'active_support/concern'
require 'active_support/core_ext/hash/except'
require 'ripple/translation'
+require 'ripple/embedded_document/around_callbacks'
require 'ripple/embedded_document/finders'
require 'ripple/embedded_document/persistence'
require 'ripple/properties'
require 'ripple/attribute_methods'
require 'ripple/timestamps'
@@ -43,10 +30,11 @@
include Ripple::AttributeMethods
include Ripple::Timestamps
include Ripple::Validations
include Ripple::Associations
include Ripple::Callbacks
+ include Ripple::EmbeddedDocument::AroundCallbacks
include Ripple::Conversion
include Finders
include Ripple::Inspection
include Ripple::NestedAttributes
include Ripple::Serialization
@@ -60,10 +48,17 @@
module InstanceMethods
def ==(other)
self.class == other.class &&
_parent_document == other._parent_document &&
- attributes.except('_type') == other.attributes.except('_type')
+ serializable_hash == other.serializable_hash
+ 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
end
end
end