Module: Mongoid::Extensions::BsonDocument
| Relationships & Source Files | |
| Defined in: | lib/mongoid/extensions/bson_document.rb |
Overview
Adds behavior to BSON::Document.
Instance Method Summary
-
#__deep_copy__ ⇒ BSON::Document
Make a deep copy of this document, preserving the BSON::Document type.
Instance Method Details
#__deep_copy__ ⇒ BSON::Document
Make a deep copy of this document, preserving the BSON::Document type.
Hash#deep_copy returns a plain Hash, which causes field_was to
return a different type than the field getter when the stored attribute
is a BSON::Document.
# File 'lib/mongoid/extensions/bson_document.rb', line 17
def __deep_copy__ self.class.new.tap do |copy| each_pair do |key, value| copy.store(key, value.__deep_copy__) end end end