Sha256: fc751583c0a6c31d78efa14ab4c063334af4a927e4b83edbdfd7b5cc8498f697

Contents?: true

Size: 981 Bytes

Versions: 2

Compression:

Stored size: 981 Bytes

Contents

class Camunda::Task < Camunda::Model
  include Camunda::VariableSerialization
  collection_path 'task'

  def self.find_by_business_key_and_task_definition_key!(instance_business_key, task_key)
    find_by(instanceBusinessKey: instance_business_key, taskDefinitionKey: task_key).tap do |ct|
      unless ct
        raise MissingTask, "Could not find Camunda Task with processInstanceBusinessKey: #{instance_business_key} " \
              "and taskDefinitionKey #{task_key}"
      end
    end
  end

  def self.mark_task_completed!(instance_business_key, task_key, variables={})
    ct = find_by_business_key_and_task_definition_key!(instance_business_key, task_key)
    ct.complete! variables
  end

  def complete!(vars)
    self.class.post_raw("#{self.class.collection_path}/#{id}/complete", variables: serialize_variables(vars))[:response]
        .tap do |response|
      raise MissingTask unless response.success?
    end
  end

  class MissingTask < StandardError
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
camunda-workflow-0.1.1 lib/camunda/task.rb
camunda-workflow-0.1 lib/camunda/task.rb