Class: Hanami::Events::CloudPubsub::Subscriber Private
- Inherits:
-
Subscriber
- Object
- Subscriber
- Hanami::Events::CloudPubsub::Subscriber
- Defined in:
- lib/hanami/events/cloud_pubsub/subscriber.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Subscriber class for calling subscriber blocks, with extra support for passing the raw message.
Instance Method Summary collapse
- #call(event_name, payload, message) ⇒ Object private
-
#initialize(event_name, handler, logger = nil, data_struct_class = nil) ⇒ Subscriber
constructor
private
A new instance of Subscriber.
Constructor Details
#initialize(event_name, handler, logger = nil, data_struct_class = nil) ⇒ Subscriber
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Subscriber.
13 14 15 16 |
# File 'lib/hanami/events/cloud_pubsub/subscriber.rb', line 13 def initialize(event_name, handler, logger = nil, data_struct_class = nil) super @handler = handler end |
Instance Method Details
#call(event_name, payload, message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hanami/events/cloud_pubsub/subscriber.rb', line 18 def call(event_name, payload, ) return unless @pattern_matcher.match?(event_name) data_object = @data_struct_class ? @data_struct_class.new(payload) : payload if @handler.arity == 2 @handler.call(data_object, ) else @handler.call(data_object) end end |