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]) entries.each.with_index do |entry, i| if person = people.find(entry) 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