Class: Yes::Core::CommandHandling::AggregateTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/yes/core/command_handling/aggregate_tracker.rb

Overview

Tracks external aggregate access during command handling

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAggregateTracker

Returns a new instance of AggregateTracker.



11
12
13
# File 'lib/yes/core/command_handling/aggregate_tracker.rb', line 11

def initialize
  @accessed_external_aggregates = []
end

Instance Attribute Details

#accessed_external_aggregatesArray<Hash> (readonly)

Returns List of accessed external aggregates with their revisions.

Returns:

  • (Array<Hash>)

    List of accessed external aggregates with their revisions



9
10
11
# File 'lib/yes/core/command_handling/aggregate_tracker.rb', line 9

def accessed_external_aggregates
  @accessed_external_aggregates
end

Instance Method Details

#track(attribute_name:, id:, revision:, context:) ⇒ void

This method returns an undefined value.

Tracks an external aggregate access

Parameters:

  • attribute_name (Symbol)

    The attribute name

  • id (String)

    The aggregate ID

  • revision (Integer)

    The aggregate revision

  • context (String)

    The context name



22
23
24
25
26
27
28
29
# File 'lib/yes/core/command_handling/aggregate_tracker.rb', line 22

def track(attribute_name:, id:, revision:, context:)
  accessed_external_aggregates << {
    id:,
    context:,
    name: attribute_name.to_s.camelize,
    revision:
  }
end