Class: Dsu::Presenters::Project::UsePresenter

Inherits:
BasePresenterEx show all
Includes:
Defaultable
Defined in:
lib/dsu/presenters/project/use_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_name:, options: {}) ⇒ UsePresenter

Returns a new instance of UsePresenter.

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
# File 'lib/dsu/presenters/project/use_presenter.rb', line 17

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

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

  self.project_name = project_name
end

Instance Attribute Details

#project_nameObject

Returns the value of attribute project_name.



13
14
15
# File 'lib/dsu/presenters/project/use_presenter.rb', line 13

def project_name
  @project_name
end

Instance Method Details

#already_current_project?Boolean



32
33
34
# File 'lib/dsu/presenters/project/use_presenter.rb', line 32

def already_current_project?
  project&.current_project?
end

#project_does_not_exist?Boolean



36
37
38
# File 'lib/dsu/presenters/project/use_presenter.rb', line 36

def project_does_not_exist?
  !project.exist?
end

#project_errorsObject



40
41
42
43
44
# File 'lib/dsu/presenters/project/use_presenter.rb', line 40

def project_errors
  return false unless project.persisted?

  project.errors.full_messages
end

#respond(response:) ⇒ Object



25
26
27
28
29
30
# File 'lib/dsu/presenters/project/use_presenter.rb', line 25

def respond(response:)
  return false unless response

  project.default! if make_default? && project&.present?
  project.use! if project&.present?
end