Sha256: c67343ab9edbd251f8cb7d49b1e6321512e8a51bc8642cc33cc489fb3f99a7f4

Contents?: true

Size: 1.44 KB

Versions: 108

Compression:

Stored size: 1.44 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?
            if log_starter
              session.logger.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

    end
  end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
eco-helpers-2.3.3 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.3.2 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.2.5 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.2.4 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.2.3 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.2.2 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.2.1 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.12 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.11 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.10 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.9 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.8 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.7 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.6 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.5 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.4 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.3 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.2 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.1.1 lib/eco/api/microcases/with_each_present.rb
eco-helpers-2.0.68 lib/eco/api/microcases/with_each_present.rb