Sha256: 22c08d6c18f395480ba6a4a2259978c2b598d46763fd5f6b133440608e992785

Contents?: true

Size: 1.25 KB

Versions: 31

Compression:

Stored size: 1.25 KB

Contents

module Eco
  module API
    class MicroCases
      # Finds each **entry** of `entries` in `people` and runs a 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.
      # @yield [entry, person] gives each entry, and the paired person thereof (new or existing).
      # @yieldparam entry [PersonEntry] the input entry with the data we should set on person.
      # @yieldparam person [Ecoportal::API::V1::Person] the found person that matches `entry`, or a new person otherwise.
      # @return [Eco::API::Organization::People] all the people, including new and existing ones.
      def with_each(entries, people, options)
        entries.map do |entry|
          unless person = people.find(entry, strict: micro.strict_search?(options))
            person = session.new_person
          end
          person.entry = entry
          yield(entry, person) if block_given?
          person
        end.yield_self {|all_people| people.newFrom all_people.uniq}
      end

    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
eco-helpers-2.0.18 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.17 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.16 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.15 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.14 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.13 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.12 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.11 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.10 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.9 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.8 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.7 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.6 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.5 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.4 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.3 lib/eco/api/microcases/with_each.rb
eco-helpers-2.0.2 lib/eco/api/microcases/with_each.rb
eco-helpers-1.5.15 lib/eco/api/microcases/with_each.rb
eco-helpers-1.5.14 lib/eco/api/microcases/with_each.rb
eco-helpers-1.5.13 lib/eco/api/microcases/with_each.rb