Class: Gcpc::Interceptors::Subscriber::DecodeInterceptor

Inherits:
Subscriber::BaseInterceptor
  • Object
show all
Defined in:
lib/gcpc/interceptors/subscriber/decode_interceptor.rb

Overview

‘DecodeInterceptor` decodes the message according to the strategy and sets it in the attributes.

Defined Under Namespace

Classes: BaseStrategy, JSONStrategy

Instance Method Summary collapse

Constructor Details

#initialize(strategy:) ⇒ DecodeInterceptor

Returns a new instance of DecodeInterceptor.

Parameters:



22
23
24
# File 'lib/gcpc/interceptors/subscriber/decode_interceptor.rb', line 22

def initialize(strategy:)
  @strategy = strategy
end

Instance Method Details

#handle(data, attributes, message, &block) {|m, attributes, message| ... } ⇒ Object

Parameters:

  • data (String)
  • attributes (Hash)
  • message (Google::Cloud::Pubsub::ReceivedMessage)
  • block (Proc)

Yields:

  • (m, attributes, message)


30
31
32
33
# File 'lib/gcpc/interceptors/subscriber/decode_interceptor.rb', line 30

def handle(data, attributes, message, &block)
  m = @strategy.decode(data, attributes, message)
  yield m, attributes, message
end