Class: Ecoportal::API::Common::GraphQL::Model::Diffable::DiffService

Inherits:
ClassicDiffService show all
Includes:
HashHelpers, HashDiffNesting
Defined in:
lib/ecoportal/api/common/graphql/model/diffable/diff_service.rb

Constant Summary

Constants included from HashDiffNesting

HashDiffNesting::META_KEYS, HashDiffNesting::NO_CHANGES

Instance Attribute Summary

Attributes inherited from ClassicDiffService

#subject

Instance Method Summary collapse

Methods included from HashHelpers::InstanceMethods

#deep_dup, #except_keys, #keys_to_s_deep, #keys_to_sym_deep, #remove_nil_keys_deep

Methods included from HashDiffNesting::InstanceMethods

#change_diff

Constructor Details

#initialize(subject, flat: false, ignore: []) ⇒ DiffService

Returns a new instance of DiffService.



6
7
8
9
10
# File 'lib/ecoportal/api/common/graphql/model/diffable/diff_service.rb', line 6

def initialize(subject, flat: false, ignore: [])
  super(subject, ignore: ignore)

  @flat = flat
end

Instance Method Details

#diff(flat: flat?, , ignore: []) ⇒ Object

Parameters:

  • flat (Boolean) (defaults to: flat?, )

    whethere it should skip nested models.

  • cascaded (Boolean)

    whether it should cascade the calls through the nested models.

    • When flat is true will only cascade the 1st level of nested models.
    • When flat is false will do a full cascade.


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ecoportal/api/common/graphql/model/diffable/diff_service.rb', line 21

def diff(flat: flat?, ignore: [])
  classic_diff(
    flat:   true,
    ignore: ignore
  ).then do |value|
    next value if flat

    diff_reduce(
      value,
      ignore: ignore
    )
  end
end

#flat?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/ecoportal/api/common/graphql/model/diffable/diff_service.rb', line 12

def flat?
  @flat
end