Class: Operaton::Bpm::Engine::Variable::VariableMap

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/operaton/bpm/engine/variable/variable_map.rb

Overview

Mirrors org.operaton.bpm.engine.variable.VariableMap: a map of variable names to typed values, with untyped access convenience.

Instance Method Summary collapse

Constructor Details

#initializeVariableMap

Returns a new instance of VariableMap.



14
15
16
# File 'lib/operaton/bpm/engine/variable/variable_map.rb', line 14

def initialize
  @map = {}
end

Instance Method Details

#eachObject



59
60
61
62
63
# File 'lib/operaton/bpm/engine/variable/variable_map.rb', line 59

def each
  return enum_for(:each) unless block_given?

  @map.each_key { |name| yield name, get_value(name) }
end

#empty?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/operaton/bpm/engine/variable/variable_map.rb', line 55

def empty?
  @map.empty?
end

#get_value(name) ⇒ Object Also known as: []

Mirrors VariableMap#getValue (raw value access)



31
32
33
34
# File 'lib/operaton/bpm/engine/variable/variable_map.rb', line 31

def get_value(name)
  typed = @map[name]
  typed&.value
end

#get_value_typed(name) ⇒ Object

Mirrors VariableMap#getValueTyped



38
39
40
# File 'lib/operaton/bpm/engine/variable/variable_map.rb', line 38

def get_value_typed(name)
  @map[name]
end

#key?(name) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/operaton/bpm/engine/variable/variable_map.rb', line 46

def key?(name)
  @map.key?(name)
end

#keysObject



42
43
44
# File 'lib/operaton/bpm/engine/variable/variable_map.rb', line 42

def keys
  @map.keys
end

#put_value(name, value) ⇒ Object Also known as: []=

Mirrors VariableMap#putValue



19
20
21
# File 'lib/operaton/bpm/engine/variable/variable_map.rb', line 19

def put_value(name, value)
  put_value_typed(name, Variables.untyped_value(value))
end

#put_value_typed(name, typed_value) ⇒ Object

Mirrors VariableMap#putValueTyped



25
26
27
28
# File 'lib/operaton/bpm/engine/variable/variable_map.rb', line 25

def put_value_typed(name, typed_value)
  @map[name] = typed_value
  self
end

#sizeObject Also known as: length



50
51
52
# File 'lib/operaton/bpm/engine/variable/variable_map.rb', line 50

def size
  @map.size
end

#to_hObject



65
66
67
# File 'lib/operaton/bpm/engine/variable/variable_map.rb', line 65

def to_h
  @map.keys.to_h { |name| [name, get_value(name)] }
end