Sha256: cf5a571c8e256c4b6ed64456e08faffb9748fa5bc21f38900f14ef4d0de97e5b

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

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

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

              strict_search = session.config.people.strict_search? || 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

1 entries across 1 versions & 1 rubygems

Version Path
eco-helpers-0.7.1 lib/eco/api/usecases/default_cases/update_details_case.rb