Class: Synapse::ProcessManager::CorrelationSet

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/synapse/process_manager/correlation_set.rb

Overview

Container that tracks additions and deletions of correlations for a process instance

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCorrelationSet

Returns a new instance of CorrelationSet.



17
18
19
20
21
# File 'lib/synapse/process_manager/correlation_set.rb', line 17

def initialize
  @correlations = Set.new
  @additions = Set.new
  @deletions = Set.new
end

Instance Attribute Details

#additionsSet (readonly)

Returns:

  • (Set)


12
13
14
# File 'lib/synapse/process_manager/correlation_set.rb', line 12

def additions
  @additions
end

#correlationsSet (readonly)

Returns:

  • (Set)


9
10
11
# File 'lib/synapse/process_manager/correlation_set.rb', line 9

def correlations
  @correlations
end

#deletionsSet (readonly)

Returns:

  • (Set)


15
16
17
# File 'lib/synapse/process_manager/correlation_set.rb', line 15

def deletions
  @deletions
end

Instance Method Details

#add(correlation) ⇒ Boolean

Adds the given correlation to this set, if not previously added

Parameters:

Returns:

  • (Boolean)


34
35
36
37
38
39
40
# File 'lib/synapse/process_manager/correlation_set.rb', line 34

def add(correlation)
  if @correlations.add? correlation
    unless @deletions.delete? correlation
      @additions.add correlation
    end
  end
end

#commitundefined

Resets the tracked changes

Returns:

  • (undefined)


25
26
27
28
# File 'lib/synapse/process_manager/correlation_set.rb', line 25

def commit
  @additions.clear
  @deletions.clear
end

#delete(correlation) ⇒ Boolean

Removes the given correlation from this set, if previously added

Parameters:

Returns:

  • (Boolean)


46
47
48
49
50
51
52
# File 'lib/synapse/process_manager/correlation_set.rb', line 46

def delete(correlation)
  if @correlations.delete? correlation
    unless @additions.delete? correlation
      @deletions.add correlation
    end
  end
end