mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 01:35:34 +08:00
[SCI-5260] Add afterward and backward actions to consequence
This commit is contained in:
parent
ad960d801d
commit
04624692d3
6 changed files with 11 additions and 13 deletions
|
@ -7,7 +7,7 @@ class MyModuleStatusConsequencesJob < ApplicationJob
|
|||
error_raised = false
|
||||
my_module.transaction do
|
||||
my_module_status_consequences.each do |consequence|
|
||||
consequence.call(my_module) if consequence.public_send("#{status_changing_direction}_execution")
|
||||
consequence.public_send(status_changing_direction, my_module)
|
||||
end
|
||||
my_module.update!(status_changing: false)
|
||||
rescue StandardError => e
|
||||
|
|
|
@ -518,7 +518,7 @@ class MyModule < ApplicationRecord
|
|||
)
|
||||
else
|
||||
my_module_status.my_module_status_consequences.each do |consequence|
|
||||
consequence.call(self) if consequence.public_send("#{status_changing_direction}_execution")
|
||||
consequence.public_send(status_changing_direction, self)
|
||||
end
|
||||
update!(status_changing: false)
|
||||
end
|
||||
|
|
|
@ -3,15 +3,13 @@
|
|||
class MyModuleStatusConsequence < ApplicationRecord
|
||||
belongs_to :my_module_status
|
||||
|
||||
def forward(my_module)
|
||||
end
|
||||
|
||||
def backward(my_module)
|
||||
end
|
||||
|
||||
def runs_in_background?
|
||||
false
|
||||
end
|
||||
|
||||
def forward_execution
|
||||
true
|
||||
end
|
||||
|
||||
def backward_execution
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Just an example, to be replaced with an actual implementation
|
||||
module MyModuleStatusConsequences
|
||||
class Completion < MyModuleStatusConsequence
|
||||
def call(my_module)
|
||||
def forward(my_module)
|
||||
my_module.state = 'completed'
|
||||
my_module.completed_on = DateTime.now
|
||||
my_module.save!
|
||||
|
|
|
@ -6,7 +6,7 @@ module MyModuleStatusConsequences
|
|||
true
|
||||
end
|
||||
|
||||
def call(my_module)
|
||||
def forward(my_module)
|
||||
my_module.assigned_repositories.each do |repository|
|
||||
repository_snapshot = ::RepositorySnapshot.create_preliminary(repository, my_module)
|
||||
service = Repositories::SnapshotProvisioningService.call(repository_snapshot: repository_snapshot)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Just an example, to be replaced with an actual implementation
|
||||
module MyModuleStatusConsequences
|
||||
class Uncompletion < MyModuleStatusConsequence
|
||||
def call(my_module)
|
||||
def backward(my_module)
|
||||
return unless my_module.state == 'completed'
|
||||
|
||||
my_module.state = 'uncompleted'
|
||||
|
|
Loading…
Reference in a new issue