Skip to content

Commit

Permalink
optimize loading object
Browse files Browse the repository at this point in the history
  • Loading branch information
Giallombardo Nathan committed Aug 14, 2024
1 parent 31b6b10 commit c1718b8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/couchbase-orm/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ def initialize(model = nil, ignore_doc_type: false, **attributes)
if model
case model
when Couchbase::Collection::GetResult
doc = HashWithIndifferentAccess.new(model.content) || raise('empty response provided')
type = doc.delete(:type)
doc.delete(:id)
doc = model.content || raise('empty response provided')
type = doc.delete('type')
doc.delete('id')

if type && !ignore_doc_type && type.to_s != self.class.design_document
raise CouchbaseOrm::Error::TypeMismatchError.new(
Expand All @@ -176,7 +176,7 @@ def initialize(model = nil, ignore_doc_type: false, **attributes)
super(model.attributes.except(:id, 'type'))
else
clear_changes_information
super(decode_encrypted_attributes(**attributes.merge(Hash(model)).symbolize_keys))
super(decode_encrypted_attributes(**attributes.merge(Hash(model))))
end
else
clear_changes_information
Expand Down

0 comments on commit c1718b8

Please sign in to comment.