Sha256: f5026f0904ccdebd414952aebac3628c614d833a6f5f621f5cc000d3ecd6c210

Contents?: true

Size: 1.59 KB

Versions: 102

Compression:

Stored size: 1.59 KB

Contents

module Eco
  module API
    class MicroCases
      # Detects who in the `entries` is new in the organization 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_present [Boolean] log error message if an `entry` has match in `people`.
      # @param append_created [Boolean] whether or not a new person will be added to the `people` object.
      # @yield [entry, person] gives each **new** `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 **new** person.
      # @return [Eco::API::Organization::People] the starters.
      def with_each_starter(entries, people, options, log_present: false, append_created: true)
        starters = []
        micro.with_each(entries, people, options, append_created: append_created) do |entry, person|
          if !person.new?
            if log_present
              session.logger.error("This person (id: '#{person.id}') already exists: #{entry.to_s(:identify)}")
            end
            next
          end
          starters << person
          yield(entry, person) if block_given?
        end
        people.newFrom starters
      end

    end
  end
end

Version data entries

102 entries across 102 versions & 1 rubygems

Version Path
eco-helpers-2.7.24 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.23 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.22 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.21 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.20 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.19 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.18 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.17 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.16 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.15 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.14 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.13 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.12 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.4 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.2 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.1 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.7.0 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.6.4 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.6.3 lib/eco/api/microcases/with_each_starter.rb
eco-helpers-2.6.2 lib/eco/api/microcases/with_each_starter.rb