Sha256: 38d17b9cccc1be1528b0e04f5f1da2856e12783fbb1f627616d98a153afcda64

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module Eco
  module API
    module UseCases
      class DefaultCases
        class CreateDetailsCase < UseCases::BaseCase

          def process
            @cases.define("create-details", type: :sync) do |entries, people, session, options|
              creation = session.job_group("main").new("create", type: :create, 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)
                  session.logger.error("Entry(#{i}) - this person (id: '#{person.id}') already exists: #{entry.to_s(:identify)}")
                else
                  person = session.new_person
                  entry.set_core(person, exclude: "supervisor_id")
                  entry.set_details(person)

                  creation.add(person)
                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/create_details_case.rb