Module: Mongoid::Extensions::BsonDocument
- Defined in:
- lib/mongoid/extensions/bson_document.rb
Overview
Adds behavior to BSON::Document.
Instance Method Summary collapse
-
#__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.
17 18 19 20 21 22 23 |
# 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 |