Class: Wf::CaseCommand::RemoveWorkitemAssignment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#partyObject (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

#permanentObject (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

#workitemObject (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

#callObject



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