Class: Stoplight::Wiring::NotifierFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/stoplight/wiring/notifier_factory.rb

Class Method Summary collapse

Class Method Details

.create(notifier:, error_notifier:) ⇒ Stoplight::Notifier::FailSafe

Wraps a notifier with fail-safe mechanisms.

Parameters:

  • notifier (Stoplight::Domain::StateTransitionNotifier)

    The notifier to wrap.

  • error_notifier (Proc)

    called when wrapped data store fails

Returns:

  • (Stoplight::Notifier::FailSafe)

    The original notifier if it is already a FailSafe instance, otherwise a new FailSafe instance.



13
14
15
16
17
18
19
20
21
22
# File 'lib/stoplight/wiring/notifier_factory.rb', line 13

def create(notifier:, error_notifier:)
  case notifier
  in Infrastructure::Notifier::FailSafe if notifier.error_notifier == error_notifier
    notifier
  in Infrastructure::Notifier::FailSafe
    Infrastructure::Notifier::FailSafe.new(notifier: notifier.notifier, error_notifier:)
  else
    Infrastructure::Notifier::FailSafe.new(notifier:, error_notifier:)
  end
end