Sha256: a59321a954b68f92d7e24e72d962aafe67cfb09496bf365331a693c64f81209f

Contents?: true

Size: 939 Bytes

Versions: 22

Compression:

Stored size: 939 Bytes

Contents

# frozen_string_literal: true

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

module Dsu
  module Presenters
    module Project
      class CreatePresenter < BasePresenterEx
        delegate :project_name, to: :project

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

          @project = Models::Project.new(project_name: project_name, description: description, options: options)
        end

        def respond(response:)
          return false unless response

          project.create!
        end

        def project_already_exists?
          project.exist?
        end

        def project_errors?
          project.invalid?
        end

        def project_errors
          return [] unless project_errors?

          project.errors.full_messages
        end

        private

        attr_reader :project, :options
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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