Class: Wf::CaseCommand::StartWorkitem
- Inherits:
-
Object
- Object
- Wf::CaseCommand::StartWorkitem
- Includes:
- SimpleCommand
- Defined in:
- app/models/wf/case_command/start_workitem.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#workitem ⇒ Object
readonly
Returns the value of attribute workitem.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(workitem, user) ⇒ StartWorkitem
constructor
A new instance of StartWorkitem.
Constructor Details
#initialize(workitem, user) ⇒ StartWorkitem
Returns a new instance of StartWorkitem.
7 8 9 10 |
# File 'app/models/wf/case_command/start_workitem.rb', line 7 def initialize(workitem, user) @workitem = workitem @user = user end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'app/models/wf/case_command/start_workitem.rb', line 6 def user @user end |
#workitem ⇒ Object (readonly)
Returns the value of attribute workitem.
6 7 8 |
# File 'app/models/wf/case_command/start_workitem.rb', line 6 def workitem @workitem end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/wf/case_command/start_workitem.rb', line 12 def call raise("The workitem can not run by user.") unless workitem.real? raise("The workitem is not in state #{workitem.state}") unless workitem.enabled? # TODO: holding timeout Wf::ApplicationRecord.transaction do workitem.update!(state: :started, holding_user: user) workitem.transition.arcs.in.each do |arc| LockToken.call(workitem.case, arc.place, workitem) end end workitem end |