forked from fs/task_tracker_itis_2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
75 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Projects | ||
class Create | ||
include Interactor::Organizer | ||
|
||
organize Projects::Save, | ||
Projects::Create::CreateOwner | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Projects | ||
class Create | ||
class CreateOwner | ||
include Interactor | ||
|
||
delegate :project, :user, to: :context | ||
|
||
def call | ||
raise_error unless owner_membership.save | ||
end | ||
|
||
private | ||
|
||
def owner_membership | ||
@owner_membership ||= ProjectMembership.new(prepared_owner_membership_params) | ||
end | ||
|
||
def prepared_owner_membership_params | ||
{ | ||
project: project, | ||
user: user, | ||
role: :owner | ||
} | ||
end | ||
|
||
def raise_error | ||
project.destroy | ||
context.fail!(error: "Invalid data") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Projects | ||
class Save | ||
include Interactor | ||
|
||
delegate :project_params, to: :context | ||
|
||
def call | ||
context.project = project | ||
|
||
context.fail!(error: "Invalid data") unless project.save | ||
end | ||
|
||
private | ||
|
||
def project | ||
@project ||= Project.new(project_params) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters