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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Includer

include_missing

Class Method Details

.included(base) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/ecoportal/api/common/content/double_model/diffable.rb', line 14

def included(base)
  super

  include_missing(base, DoubleModel::HashHelpers)
  include_missing(base, DoubleModel::DoubleDoc::LinkableDoc)
  include_missing(base, DoubleModel::Attributable::Nesting::CascadedCallback)
end

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