Module: Ecoportal::API::Common::GraphQL::Model::Diffable
- Included in:
- Ecoportal::API::Common::GraphQL::Model
- Defined in:
- lib/ecoportal/api/common/graphql/model/diffable/hash_diff.rb,
lib/ecoportal/api/common/graphql/model/diffable.rb,
lib/ecoportal/api/common/graphql/model/diffable/diff_service.rb,
lib/ecoportal/api/common/graphql/model/diffable/hash_diff_nesting.rb,
lib/ecoportal/api/common/graphql/model/diffable/classic_diff_service.rb
Overview
rubocop:disable Naming/MethodParameterName
Defined Under Namespace
Modules: HashDiff, HashDiffNesting Classes: ClassicDiffService, DiffService
Constant Summary collapse
- DIFF_CLASS =
DiffService
Instance Method Summary collapse
-
#as_update(**kargs) ⇒ nil, Hash
The patch
Hash
model including only the changes betweenoriginal_doc
anddoc
. -
#dirty? ⇒ Boolean
Stating if there are changes.
Instance Method Details
#as_update(**kargs) ⇒ nil, Hash
Note:
cascaded callbacks
- Can skip rooted objects (where
root?
istrue
). This is because nested rooted objects are usually look-ups (not really part of the target model). - Allow to redefine
as_update
on each model.
Returns the patch Hash
model including only
the changes between original_doc
and doc
.
26 27 28 29 30 31 |
# File 'lib/ecoportal/api/common/graphql/model/diffable.rb', line 26 def as_update(**kargs) diff_class.new( self, **kargs ).diff end |
#dirty? ⇒ Boolean
Note:
cascaded
will be more accurate in a GraphQL
scenario.
Returns stating if there are changes.
35 36 37 38 39 40 41 42 |
# File 'lib/ecoportal/api/common/graphql/model/diffable.rb', line 35 def dirty?(...) au = as_update(...) return false if au.nil? return false if au == {} true end |