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

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.



12
13
14
15
16
17
18
19
20
21
# File 'lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb', line 12

def core_excluded(person, options)
  ['supervisor_id'].tap do |core_excluded|
    can_exclude = person.new?? ['filter_tags'] : %w[name external_id email filter_tags]

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