Module: Ecoportal::API::Common::Content::DoubleModel::DoubleDoc::ResetConsolidate
- Extended by:
- Includer
- Includes:
- VarTracking
- Defined in:
- lib/ecoportal/api/common/content/double_model/double_doc/reset_consolidate.rb
Instance Method Summary collapse
-
#consolidate! ⇒ Object
It makes
original_docto be likedoc. -
#reset!(key = nil) ⇒ Object
It makes
docto be likeoriginal.
Methods included from Includer
Instance Method Details
#consolidate! ⇒ Object
Note:
- after executing it, there will be no pending changes
- you should technically run this command, after a successful update request to the server
It makes original_doc to be like doc
29 30 31 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/reset_consolidate.rb', line 29 def consolidate! replace_original_doc(JSON.parse(doc.to_json)) end |
#reset!(key = nil) ⇒ Object
Note:
- after executing it, changes in
docwill be lost - you should technically run this command only if you want to remove certain changes
It makes doc to be like original
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ecoportal/api/common/content/double_model/double_doc/reset_consolidate.rb', line 38 def reset!(key = nil) if key keys = [key].flatten.compact odoc = original_doc.dig(*keys) odoc &&= JSON.parse(odoc.to_json) dig_set!(doc, keys, odoc) else replace_doc(JSON.parse(original_doc.to_json)) end end |