lib/ecoportal/api/common/content/double_model.rb in ecoportal-api-v2-0.8.6 vs lib/ecoportal/api/common/content/double_model.rb in ecoportal-api-v2-0.8.7

- old
+ new

@@ -149,11 +149,11 @@ dim_class.order_key = order_key end else raise "You should either specify the 'klass' of the elements or the 'enum_class'" end - embed(method, key: key, multiple: true, klass: eclass) + embed(method, key: key, multiple: true, klass: eclass) end private def embed(method, key: method, nullable: false, multiple: false, klass:) @@ -256,13 +256,13 @@ replace_original_doc(JSON.parse(doc.to_json)) end def reset!(key = nil) if key - keys = [].push(key).compact + keys = [key].flatten.compact odoc = original_doc.dig(*keys) - dig_set(doc, key, odoc && JSON.parse(odoc.to_json)) - + odoc = odoc && JSON.parse(odoc.to_json) + dig_set(doc, keys, odoc) else replace_doc(JSON.parse(original_doc.to_json)) end end