Class: Wf::CaseCommand::BeginWorkitemAction
- Inherits:
-
Object
- Object
- Wf::CaseCommand::BeginWorkitemAction
- Includes:
- SimpleCommand
- Defined in:
- app/models/wf/case_command/begin_workitem_action.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#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, action = :start) ⇒ BeginWorkitemAction
constructor
A new instance of BeginWorkitemAction.
Constructor Details
#initialize(workitem, user, action = :start) ⇒ BeginWorkitemAction
Returns a new instance of BeginWorkitemAction.
7 8 9 10 11 |
# File 'app/models/wf/case_command/begin_workitem_action.rb', line 7 def initialize(workitem, user, action = :start) @workitem = workitem @action = action @user = user end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
6 7 8 |
# File 'app/models/wf/case_command/begin_workitem_action.rb', line 6 def action @action end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'app/models/wf/case_command/begin_workitem_action.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/begin_workitem_action.rb', line 6 def workitem @workitem end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/wf/case_command/begin_workitem_action.rb', line 13 def call if action == :start raise("Workitem is in state #{workitem.state}, but it must be in state enabled to be started.") unless workitem.enabled? raise("You are not assigned to this workitem.") unless workitem.owned_by?(user) elsif action == :finish || action == :cancel if workitem.started? raise("You are not the user currently working on this workitem.") if workitem.holding_user != user elsif workitem.enabled? raise("You can only cancel a workitem in state started, but this workitem is in state #{workitem.state}.") if action == :cancel raise("You are not assigned to this workitem.") unless workitem.owned_by?(user) workitem.update!(holding_user: user) else raise("Workitem is in state #{workitem.state}, but it must be in state enabled or started to be finished.") end elsif action == :comment # TODO end end |