48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/locomotive/mongoid/patches.rb', line 48
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
|