Class: Dsu::Presenters::Project::UsePresenter
- Inherits:
-
BasePresenterEx
- Object
- BasePresenterEx
- Dsu::Presenters::Project::UsePresenter
- Includes:
- Defaultable
- Defined in:
- lib/dsu/presenters/project/use_presenter.rb
Instance Attribute Summary collapse
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
Instance Method Summary collapse
- #already_current_project? ⇒ Boolean
-
#initialize(project_name:, options: {}) ⇒ UsePresenter
constructor
A new instance of UsePresenter.
- #project_does_not_exist? ⇒ Boolean
- #project_errors ⇒ Object
- #respond(response:) ⇒ Object
Constructor Details
#initialize(project_name:, options: {}) ⇒ UsePresenter
Returns a new instance of UsePresenter.
17 18 19 20 21 22 23 |
# File 'lib/dsu/presenters/project/use_presenter.rb', line 17 def initialize(project_name:, options: {}) super(options: ) raise ArgumentError, 'project_name is blank' if project_name.blank? self.project_name = project_name end |
Instance Attribute Details
#project_name ⇒ Object
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_errors ⇒ Object
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. 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 |