Sha256: 0cc1110eaf51739c63d8cff6a5a47a89770783455efdbf7a4ace2692c5b24aa4

Contents?: true

Size: 1.19 KB

Versions: 22

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require_relative '../../models/project'
require_relative '../base_presenter_ex'

module Dsu
  module Presenters
    module Project
      class DeletePresenter < BasePresenterEx
        attr_reader :project_name

        delegate :description, to: :project, prefix: true, allow_nil: true

        def initialize(project_name:, options: {})
          super(options: options)

          raise ArgumentError, 'project_name is blank' if project_name.blank?

          self.project_name = project_name
        end

        def respond(response:)
          return false unless response
          return false if project_does_not_exist? || project_default?

          project.delete! if project&.present?
        end

        def project_does_not_exist?
          !project.exist?
        end

        def project_default?
          project.default_project?
        end

        def project_errors
          return false unless project.persisted?

          project.errors.full_messages
        end

        private

        attr_writer :project_name

        def project
          @project ||= Models::Project.find_or_initialize(project_name: project_name)
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
dsu-3.0.5 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.4 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.3 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.1 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.beta.3 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.beta.2 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.beta.1 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.beta.0 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.alpha.12 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.alpha.11 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.alpha.10 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.alpha.9 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.alpha.8 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.alpha.7 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.alpha.6 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.alpha.5 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.alpha.4 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.alpha.3 lib/dsu/presenters/project/delete_presenter.rb
dsu-3.0.0.alpha.2 lib/dsu/presenters/project/delete_presenter.rb