Class: Gcpc::Subscriber::HandleEngine
- Inherits:
-
Object
- Object
- Gcpc::Subscriber::HandleEngine
- Defined in:
- lib/gcpc/subscriber/handle_engine.rb
Overview
HandleEngine handle messages and exceptions with interceptors.
Instance Method Summary collapse
- #handle(message) ⇒ Object
-
#initialize(handler:, interceptors:) ⇒ HandleEngine
constructor
A new instance of HandleEngine.
- #on_error(error) ⇒ Object
Constructor Details
#initialize(handler:, interceptors:) ⇒ HandleEngine
Returns a new instance of HandleEngine.
7 8 9 10 |
# File 'lib/gcpc/subscriber/handle_engine.rb', line 7 def initialize(handler:, interceptors:) @handler = (handler.class == Class) ? handler.new : handler @interceptors = interceptors.map { |i| (i.class == Class) ? i.new : i } end |
Instance Method Details
#handle(message) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/gcpc/subscriber/handle_engine.rb', line 13 def handle() d = .data.dup a = .attributes.dup (@interceptors, d, a, ) do |dd, aa, m| (dd, aa, m) end end |
#on_error(error) ⇒ Object
23 24 25 26 27 |
# File 'lib/gcpc/subscriber/handle_engine.rb', line 23 def on_error(error) intercept_error!(@interceptors, error) do |e| handle_on_error(e) end end |