Module: Ecoportal::API::Common::Content::DoubleModel::DiffableModel

Extended by:
Includer
Included in:
Ecoportal::API::Common::Content::DoubleModel
Defined in:
lib/ecoportal/api/common/content/double_model/diffable_model.rb

Instance Method Summary collapse

Methods included from Includer

include_missing

Instance Method Details

#as_updatenil, Hash

Returns the patch Hash model including only the changes between original_doc and doc.

Returns:

  • (nil, Hash)

    the patch Hash model including only the changes between original_doc and doc.



23
24
25
26
27
28
# File 'lib/ecoportal/api/common/content/double_model/diffable_model.rb', line 23

def as_update
  HashDiffPatch.patch_diff(
    as_json,
    original_doc
  )
end

#dirty?Boolean

Returns stating if there are changes.

Returns:

  • (Boolean)

    stating if there are changes.



31
32
33
34
35
36
37
# File 'lib/ecoportal/api/common/content/double_model/diffable_model.rb', line 31

def dirty?
  au = as_update
  return false if au.nil?
  return false if au == {}

  true
end