Class: Wf::CaseCommand::ClearWorkitemAssignments

Inherits:
Object
  • Object
show all
Includes:
SimpleCommand
Defined in:
app/models/wf/case_command/clear_workitem_assignments.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workitem, permanent = true) ⇒ ClearWorkitemAssignments

Returns a new instance of ClearWorkitemAssignments.



7
8
9
10
# File 'app/models/wf/case_command/clear_workitem_assignments.rb', line 7

def initialize(workitem, permanent = true)
  @workitem = workitem
  @permanent = permanent
end

Instance Attribute Details

#permanentObject (readonly)

Returns the value of attribute permanent.



6
7
8
# File 'app/models/wf/case_command/clear_workitem_assignments.rb', line 6

def permanent
  @permanent
end

#workitemObject (readonly)

Returns the value of attribute workitem.



6
7
8
# File 'app/models/wf/case_command/clear_workitem_assignments.rb', line 6

def workitem
  @workitem
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
# File 'app/models/wf/case_command/clear_workitem_assignments.rb', line 12

def call
  Wf::ApplicationRecord.transaction do
    ClearManualAssignments.call(workitem.case, workitem.transition) if permanent
    workitem.workitem_assignments.delete_all
    workitem.transition.unassignment_callback.constantize.new(workitem.id).perform
  end
end