Class: Wf::CaseCommand::ReleaseToken

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workitem) ⇒ ReleaseToken

Returns a new instance of ReleaseToken.



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

def initialize(workitem)
  @workitem = workitem
end

Instance Attribute Details

#workitemObject (readonly)

Returns the value of attribute workitem.



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

def workitem
  @workitem
end

Instance Method Details

#callObject



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

def call
  Wf::ApplicationRecord.transaction do
    Wf::Token.where(locked_workitem_id: workitem.id).locked.each do |token|
      AddToken.call(token.case, token.place)
      token.update!(state: :canceled, canceled_at: Time.zone.now)
    end
  end
end