Class: AggregateRoot::InstrumentedApplyStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/aggregate_root/instrumented_apply_strategy.rb

Instance Method Summary collapse

Constructor Details

#initialize(strategy, instrumentation) ⇒ InstrumentedApplyStrategy

Returns a new instance of InstrumentedApplyStrategy.



5
6
7
8
# File 'lib/aggregate_root/instrumented_apply_strategy.rb', line 5

def initialize(strategy, instrumentation)
  @strategy = strategy
  @instrumentation = instrumentation
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/aggregate_root/instrumented_apply_strategy.rb', line 18

def method_missing(method_name, *arguments, &block)
  if respond_to?(method_name)
    strategy.public_send(method_name, *arguments, &block)
  else
    super
  end
end

Instance Method Details

#call(aggregate, event) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/aggregate_root/instrumented_apply_strategy.rb', line 10

def call(aggregate, event)
  instrumentation.instrument("apply.aggregate_root",
    aggregate: aggregate,
    event:     event) do
    strategy.call(aggregate, event)
  end
end

#respond_to_missing?(method_name, _include_private) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/aggregate_root/instrumented_apply_strategy.rb', line 26

def respond_to_missing?(method_name, _include_private)
  strategy.respond_to?(method_name)
end