Module: Eco::API::MicroCases::People::ApplyChanges::SetCore::CoreExcluded

Included in:
Eco::API::MicroCases::People::ApplyChanges::SetCore
Defined in:
lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb

Constant Summary collapse

CAN_EXCLUDE_CREATION =
%w[
  filter_tags archived
  contractor_organization_id
].freeze
CAN_EXCLUDE_UPDATE =
%w[
  name external_id email
  filter_tags contractor_organization_id
].freeze

Instance Method Summary collapse

Instance Method Details

#core_excluded(person, options) ⇒ Array<String>

Note:

by default supervisor_id is always excluded.

Returns the core parameters that should not be included.

Parameters:

  • person (Ecoportal::API::V1::Person)

    the person we want to update, carrying the changes to be done.

  • options (Hash)

    the options.

Returns:

  • (Array<String>)

    the core parameters that should not be included.



21
22
23
24
25
26
27
28
29
30
# File 'lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb', line 21

def core_excluded(person, options)
  ['supervisor_id'].tap do |core_excluded|
    can_exclude = person.new?? CAN_EXCLUDE_CREATION : CAN_EXCLUDE_UPDATE

    exclusions  = can_exclude.select do |attr|
      options.dig(:exclude, attr.to_sym)
    end
    core_excluded.concat(exclusions)
  end
end