Sha256: a755ea4754dfb2bef7fd8d65c84b17be9a9bcadb98e9896ca5dafad3b037bb7b

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

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

          def process

            @cases.define("remove-account", type: :transform) do |people, session|
              update = session.job_group("main").new("update", 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|
              update = session.job_group("main").new("update", 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

5 entries across 5 versions & 1 rubygems

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