From c1718b8110f8b069a6167cd45bda09627a879e71 Mon Sep 17 00:00:00 2001 From: Giallombardo Nathan Date: Wed, 14 Aug 2024 14:49:29 +0000 Subject: [PATCH] optimize loading object --- lib/couchbase-orm/base.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/couchbase-orm/base.rb b/lib/couchbase-orm/base.rb index 317c1a63..19ce3836 100644 --- a/lib/couchbase-orm/base.rb +++ b/lib/couchbase-orm/base.rb @@ -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( @@ -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