Module: Ecoportal::API::Common::Content::DoubleModel::Diffable

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

Defined Under Namespace

Classes: PatchDiffService

Constant Summary collapse

DIFF_CLASS =
PatchDiffService

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.



27
28
29
# File 'lib/ecoportal/api/common/content/double_model/diffable.rb', line 27

def as_update
  diff_class.new(self).diff
end

#dirty?Boolean

Returns stating if there are changes.

Returns:

  • (Boolean)

    stating if there are changes.



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

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

  true
end