Class: Wf::CaseCommand::LockToken

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wf_case, place, workitem) ⇒ LockToken

Returns a new instance of LockToken.



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

def initialize(wf_case, place, workitem)
  @wf_case = wf_case
  @place = place
  @workitem = workitem
end

Instance Attribute Details

#placeObject (readonly)

Returns the value of attribute place.



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

def place
  @place
end

#wf_caseObject (readonly)

Returns the value of attribute wf_case.



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

def wf_case
  @wf_case
end

#workitemObject (readonly)

Returns the value of attribute workitem.



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

def workitem
  @workitem
end

Instance Method Details

#callObject



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

def call
  wf_case.tokens.free.where(place: place).limit(1).update_all(
    state: :locked,
    locked_at: Time.zone.now,
    locked_workitem_id: workitem.id
  )
end