Module: Eco::API::MicroCases::People::Fetch::WithEachPresent

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

Instance Method Summary collapse

Instance Method Details

#with_each_present(entries, people, options, log_starter: false) {|entry, person| ... } ⇒ Eco::API::Organization::People

Note:
  • it also links to person.entry the input data entry.

Finds those in entries that already exist in the organization (people) and yield s them one by one to the given block.

Parameters:

Yields:

  • (entry, person)

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

Yield Parameters:

  • entry (PersonEntry)

    the input entry with the data we should set on person.

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

    the found person.

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/eco/api/microcases/people/fetch/with_each_present.rb', line 18

def with_each_present(entries, people, options, log_starter: false)
  found = []
  micro.with_each(entries, people, options) do |entry, person|
    if person.new?
      if log_starter
        log(:error) {
          "This person does not exist: #{entry.to_s(:identify)}"
        }
      end

      next
    end

    found << person
    yield(entry, person) if block_given?
  end

  people.newFrom found
end