Sha256: 536ef22415aaf6a322f10b0a481747d2c82227d4f1747bbb9fb44ec1daefce98

Contents?: true

Size: 1.22 KB

Versions: 41

Compression:

Stored size: 1.22 KB

Contents

module Eco
  module API
    class MicroCases
      # Detects who has left the organization and `yield` s them one by one to the given block
      # @note
      #   - To be used only when the input file is the full DB
      #   - The `Entries#find` method. If the people manager entry does not have `external_id`,
      #     but has a matching `email` wiht some input entry (row), it won't be identified as a leaver.
      # @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 [person] gives each person of `people` that is not present in `entries`.
      # @yieldparam person [Ecoportal::API::V1::Person] the person that leaves the org.
      # @return [Eco::API::Organization::People] the leavers.
      def with_each_leaver(entries, people, options)
        leavers = people.map do |person|
          unless entries.find(person, strict: micro.strict_search?(options))
            yield(person) if block_given?
            person
          end
        end.compact
        people.newFrom leavers
      end

    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
eco-helpers-2.6.1 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.6.0 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.5.10 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.5.9 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.5.8 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.5.7 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.5.6 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.5.5 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.5.4 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.5.3 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.5.2 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.5.1 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.4.9 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.4.8 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.4.7 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.4.6 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.4.5 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.4.4 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.4.3 lib/eco/api/microcases/with_each_leaver.rb
eco-helpers-2.4.2 lib/eco/api/microcases/with_each_leaver.rb