Sha256: bce3a7b26507ed0462e67b9832e3145c05abc44648f60225c52e54f5e9cc8065
Contents?: true
Size: 1.41 KB
Versions: 31
Compression:
Stored size: 1.41 KB
Contents
module Eco module API class MicroCases # Finds those in `entries` that already exist in the organization (`people`) and `yield` s them one by one to the given block. # @note # - it also links to `person.entry` the input data `entry`. # @param entries [Eco::API::Common::People::Entries] the input entries with the data. # @param people [Eco::API::Organization::People] target existing _People_ of the current update. # @param options [Hash] the options. # @param log_starter [Boolean] log error message if an `entry` does not have match in `people`. # @yield [entry, person] gives each **found** `person` of `entries` that is not present in `people`. # @yieldparam entry [PersonEntry] the input entry with the data we should set on person. # @yieldparam person [Ecoportal::API::V1::Person] the **found** person. # @return [Eco::API::Organization::People] the found people. def with_each_present(entries, people, options, log_starter: false) found = [] micro.with_each(entries, people, options) do |entry, person| if person.new? && log_starter session.logger.error("This person does not exist: #{entry.to_s(:identify)}") next end found << person yield(entry, person) if block_given? end people.newFrom found end end end end
Version data entries
31 entries across 31 versions & 1 rubygems