Class: Wf::CaseCommand::RemoveWorkitemAssignment
- Inherits:
-
Object
- Object
- Wf::CaseCommand::RemoveWorkitemAssignment
- Includes:
- SimpleCommand
- Defined in:
- app/models/wf/case_command/remove_workitem_assignment.rb
Instance Attribute Summary collapse
-
#party ⇒ Object
readonly
Returns the value of attribute party.
-
#permanent ⇒ Object
readonly
Returns the value of attribute permanent.
-
#workitem ⇒ Object
readonly
Returns the value of attribute workitem.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(workitem, party, permanent = true) ⇒ RemoveWorkitemAssignment
constructor
A new instance of RemoveWorkitemAssignment.
Constructor Details
#initialize(workitem, party, permanent = true) ⇒ RemoveWorkitemAssignment
Returns a new instance of RemoveWorkitemAssignment.
7 8 9 10 11 |
# File 'app/models/wf/case_command/remove_workitem_assignment.rb', line 7 def initialize(workitem, party, permanent = true) @workitem = workitem @party = party @permanent = permanent end |
Instance Attribute Details
#party ⇒ Object (readonly)
Returns the value of attribute party.
6 7 8 |
# File 'app/models/wf/case_command/remove_workitem_assignment.rb', line 6 def party @party end |
#permanent ⇒ Object (readonly)
Returns the value of attribute permanent.
6 7 8 |
# File 'app/models/wf/case_command/remove_workitem_assignment.rb', line 6 def permanent @permanent end |
#workitem ⇒ Object (readonly)
Returns the value of attribute workitem.
6 7 8 |
# File 'app/models/wf/case_command/remove_workitem_assignment.rb', line 6 def workitem @workitem end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/wf/case_command/remove_workitem_assignment.rb', line 13 def call return if party.nil? Wf::ApplicationRecord.transaction do RemoveManualAssignment.call(workitem.case, workitem.transition, party) if permanent workitem.workitem_assignments.where(party: party).first&.destroy workitem.transition.unassignment_callback.constantize.new(workitem.id).perform_now if workitem.workitem_assignments.count == 0 end end |