Sha256: 504d788de100ed79ea8bdacb15bd450e929ef8156733654a523c8a7677fc1cec

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 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[:search]&.key?(:strict) || 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

5 entries across 5 versions & 1 rubygems

Version Path
eco-helpers-0.8.4 lib/eco/api/usecases/default_cases/create_details_case.rb
eco-helpers-0.8.3 lib/eco/api/usecases/default_cases/create_details_case.rb
eco-helpers-0.8.2 lib/eco/api/usecases/default_cases/create_details_case.rb
eco-helpers-0.8.1 lib/eco/api/usecases/default_cases/create_details_case.rb
eco-helpers-0.7.2 lib/eco/api/usecases/default_cases/create_details_case.rb