Module: Eco::API::MicroCases::People::Fetch::WithEachLeaver

Included in:
Eco::API::MicroCases::People::Fetch
Defined in:
lib/eco/api/microcases/people/fetch/with_each_leaver.rb

Instance Method Summary collapse

Instance Method Details

#with_each_leaver(entries, people, options) {|person| ... } ⇒ Eco::API::Organization::People

Note:
  • To be used only when the input file is the full DB
  • The Entries#find method. If the people manager entry does not have external_id, but has a matching email wiht some input entry (row), it won't be identified as a leaver.

Detects who has left the organization and yield s them one by one to the given block

Parameters:

Yields:

  • (person)

    gives each person of people that is not present in entries.

Yield Parameters:

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

    the person that leaves the org.

Returns:



18
19
20
21
22
23
24
25
26
27
# File 'lib/eco/api/microcases/people/fetch/with_each_leaver.rb', line 18

def with_each_leaver(entries, people, options)
  leavers = people.map do |person|
    unless entries.find(person, strict: micro.strict_search?(options))
      yield(person) if block_given?
      person
    end
  end.compact

  people.newFrom leavers
end