Class: Wf::CaseCommand::CancelWorkitem
- Inherits:
-
Object
- Object
- Wf::CaseCommand::CancelWorkitem
- Includes:
- SimpleCommand
- Defined in:
- app/models/wf/case_command/cancel_workitem.rb
Instance Attribute Summary collapse
-
#workitem ⇒ Object
readonly
Returns the value of attribute workitem.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(workitem) ⇒ CancelWorkitem
constructor
A new instance of CancelWorkitem.
Constructor Details
#initialize(workitem) ⇒ CancelWorkitem
Returns a new instance of CancelWorkitem.
7 8 9 |
# File 'app/models/wf/case_command/cancel_workitem.rb', line 7 def initialize(workitem) @workitem = workitem end |
Instance Attribute Details
#workitem ⇒ Object (readonly)
Returns the value of attribute workitem.
6 7 8 |
# File 'app/models/wf/case_command/cancel_workitem.rb', line 6 def workitem @workitem end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/models/wf/case_command/cancel_workitem.rb', line 11 def call raise("The workitem is not in state #{workitem.state}") unless workitem.started? Wf::ApplicationRecord.transaction do workitem.update!(state: :canceled, canceled_at: Time.zone.now) ReleaseToken.call(workitem) SweepAutomaticTransitions.call(workitem.case) end end |