Sha256: dbc7eb4a49b1e5a1ffc7862ea8e687243a0318f011bcaf7c708636c0157126b1

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# A process instance is an individual execution of a process definition. The relation of the process instance to the process
# definition is the same as the relation between Class and Class instance in OOP. When a process definition is started,
# a process instance is created.
# @see https://docs.camunda.org/manual/7.4/user-guide/process-engine/process-engine-concepts/
# @see Camunda::ProcessDefinition
class Camunda::ProcessInstance < Camunda::Model
  uri 'process-instance/(:id)'
  # GETs the process instance and deserializes the variables
  def variables
    response = self.class.request(:get, "process-instance/#{id}/variables")
    deserialize_variables response.body[:data]
  end

  private

  # Deserialize variables and convert variable names from CamelCase to snake_case.
  # @param hash [Hash] Transforms a hash of Camunda serialized variables to a simple Ruby hash and snake_cases variable names
  def deserialize_variables(hash)
    hash.transform_values do |value_hash|
      case value_hash[:type]
      when "String", "Double", "Integer", "Boolean"
        value_hash[:value]
      when "Json"
        value_hash[:value][:node_type]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
camunda-workflow-1.0.0 lib/camunda/process_instance.rb