Sha256: 3424606f9f3efb9efd3b6a5ec9f1dd6751f6ff42495e5d044b8f80831b047a69

Contents?: true

Size: 1.18 KB

Versions: 7

Compression:

Stored size: 1.18 KB

Contents

module Eco
  module API
    class UseCases
      class DefaultCases
        class UpdateDetailsCase < DefaultCase

          def process
            @cases.define("update-details", type: :sync) do |entries, people, session, options, usecase|
              job = session.job_group("main").new("update", usecase: usecase, type: :update, sets: [:core, :details])

              strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict))

              entries.each.with_index do |entry, i|
                if person = people.find(entry, strict: strict_search)
                  core_excluded = ["supervisor_id"]
                  core_excluded.push("email") if options.dig(:exclude, :email)
                  entry.set_core(person, exclude: core_excluded) unless options.dig(:exclude, :core)
                  entry.set_details(person)

                  job.add(person)
                else
                  session.logger.error("Entry(#{i}) - this person does not exist: #{entry.to_s(:identify)}")
                end
              end
            end
          end

        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
eco-helpers-1.0.5 lib/eco/api/usecases/default_cases/update_details_case.rb
eco-helpers-1.0.4 lib/eco/api/usecases/default_cases/update_details_case.rb
eco-helpers-1.0.3 lib/eco/api/usecases/default_cases/update_details_case.rb
eco-helpers-0.9.5 lib/eco/api/usecases/default_cases/update_details_case.rb
eco-helpers-1.0.2 lib/eco/api/usecases/default_cases/update_details_case.rb
eco-helpers-0.9.4 lib/eco/api/usecases/default_cases/update_details_case.rb
eco-helpers-0.9.3 lib/eco/api/usecases/default_cases/update_details_case.rb