Class: Mistri::EventDelivery::Boundary
- Inherits:
-
Object
- Object
- Mistri::EventDelivery::Boundary
- Defined in:
- lib/mistri/event_delivery.rb
Overview
Wraps one subscriber and unwraps only failures that it created.
Instance Method Summary collapse
- #call(event) ⇒ Object
-
#initialize(subscriber, passthrough: []) ⇒ Boundary
constructor
A new instance of Boundary.
- #to_proc ⇒ Object
- #unwrap(error) ⇒ Object
Constructor Details
#initialize(subscriber, passthrough: []) ⇒ Boundary
Returns a new instance of Boundary.
20 21 22 23 24 |
# File 'lib/mistri/event_delivery.rb', line 20 def initialize(subscriber, passthrough: []) @subscriber = subscriber @passthrough = passthrough.freeze @callable = method(:call).to_proc end |
Instance Method Details
#call(event) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/mistri/event_delivery.rb', line 28 def call(event) @subscriber.call(event) rescue Failure raise rescue StandardError => e raise if @passthrough.any? { |error_class| e.is_a?(error_class) } raise Failure.new(e, self) end |
#to_proc ⇒ Object
26 |
# File 'lib/mistri/event_delivery.rb', line 26 def to_proc = @callable |
#unwrap(error) ⇒ Object
38 39 40 |
# File 'lib/mistri/event_delivery.rb', line 38 def unwrap(error) error.boundary.equal?(self) ? error.original : error end |