Sha256: 02d726f14bd491d089a36a03708aabbd8a7229368eace0fdc0271809aed7b053

Contents?: true

Size: 1.16 KB

Versions: 14

Compression:

Stored size: 1.16 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
  collection_path 'process-instance'
  # GETs the process instance and deserializes the variables
  def variables
    response = self.class.get_raw "process-instance/#{id}/variables"
    deserialize_variables response[:parsed_data][: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

14 entries across 14 versions & 1 rubygems

Version Path
camunda-workflow-0.6.0 lib/camunda/process_instance.rb
camunda-workflow-0.5.0 lib/camunda/process_instance.rb
camunda-workflow-0.4.1 lib/camunda/process_instance.rb
camunda-workflow-0.4.0 lib/camunda/process_instance.rb
camunda-workflow-0.3.3 lib/camunda/process_instance.rb
camunda-workflow-0.3.2 lib/camunda/process_instance.rb
camunda-workflow-0.3.1 lib/camunda/process_instance.rb
camunda-workflow-0.3.0 lib/camunda/process_instance.rb
camunda-workflow-0.2.3 lib/camunda/process_instance.rb
camunda-workflow-0.2.2 lib/camunda/process_instance.rb
camunda-workflow-0.2.1 lib/camunda/process_instance.rb
camunda-workflow-0.2.0 lib/camunda/process_instance.rb
camunda-workflow-0.1.5 lib/camunda/process_instance.rb
camunda-workflow-0.1.4 lib/camunda/process_instance.rb