Sha256: 72e8a1b1f641a4d0cbb2d4b5035243367e882bd8258224b0b7c8da054f3aff38

Contents?: true

Size: 1.32 KB

Versions: 40

Compression:

Stored size: 1.32 KB

Contents

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

          def process

            @cases.define("remove-account", type: :transform) do |people, session, options, usecase|
              update = session.job_group("main").new("update", usecase: usecase, type: :update, sets: [:core, :account])
              people.users.map do |person|
                person.account = nil
                update.add(person)
              end
            end

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

              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)
                  person.account = nil
                  update.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

40 entries across 40 versions & 1 rubygems

Version Path
eco-helpers-1.5.1 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.5.0 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.4.2 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.19 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.4.1 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.4.0 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.18 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.17 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.16 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.15 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.14 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.13 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.12 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.11 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.10 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.9 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.8 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.7 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.6 lib/eco/api/usecases/default_cases/remove_account_case.rb
eco-helpers-1.3.5 lib/eco/api/usecases/default_cases/remove_account_case.rb