Class: Axn::Core::Flow::Handlers::SingleRuleMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/axn/core/flow/handlers/matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(rule, invert: false) ⇒ SingleRuleMatcher

Returns a new instance of SingleRuleMatcher.



10
11
12
13
# File 'lib/axn/core/flow/handlers/matcher.rb', line 10

def initialize(rule, invert: false)
  @rule = rule
  @invert = invert
end

Instance Method Details

#call(exception:, action:) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/axn/core/flow/handlers/matcher.rb', line 15

def call(exception:, action:)
  # A matcher's error policy is set ONE layer down, by Handlers::Invoker, which warns and
  # yields nil (so the rule reads as "no match") for anything axn absorbs. Deliberately NOT
  # `standard_errors_only:` on top of that: a second, stricter layer here would make a matcher
  # raising SystemStackError behave differently from one raising ArgumentError, and worse —
  # since on_success/error matchers are evaluated inside the executor's boundary, letting one
  # through would settle a SUCCESSFUL action as an exception carrying the matcher's own bug.
  # A broken matcher is loud in the log and inert in its effect; it never rewrites the outcome.
  Axn::Extensions.best_effort("determining if handler applies to exception", action:) do
    result = matches?(exception:, action:)
    @invert ? !result : result
  end
end