Codeminer42/cm42-central

View on GitHub
app/operations/team_operations/destroy.rb

Summary

Maintainability
A
0 mins
Test Coverage
module TeamOperations
  class Destroy
    include Operation

    def initialize(team:, current_user:)
      @team = team
      @current_user = current_user
    end

    def call
      ActiveRecord::Base.transaction do
        yield delete_team

        Success(team)
      end
    rescue
      Failure(team)
    end

    private

    attr_reader :team, :current_user

    def delete_team
      Success(team.update(archived_at: Time.current))
    end
  end
end