70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/locomotive/mongoid/patches.rb', line 70
def with_same_class!(document, klass)
return document if document.is_a?(klass)
Factory.build(klass, {}).tap do |_document|
_document.apply_post_processed_defaults
integrate(_document)
attributes = document.attributes
attributes['_type'] = _document._type
_document.instance_variable_set(:@attributes, attributes)
_document.new_record = document.new_record?
_document._index = document._index
target[_document._index] = _document
_unscoped[_document._index] = _document
end
end
|