Class: MessageDriver::Middleware::BlockMiddleware
- Defined in:
- lib/message_driver/middleware/block_middleware.rb
Instance Attribute Summary collapse
-
#on_consume_block ⇒ Object
readonly
Returns the value of attribute on_consume_block.
-
#on_publish_block ⇒ Object
readonly
Returns the value of attribute on_publish_block.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(destination, opts) ⇒ BlockMiddleware
constructor
A new instance of BlockMiddleware.
- #on_consume(body, headers, properties) ⇒ Object
- #on_publish(body, headers, properties) ⇒ Object
Constructor Details
#initialize(destination, opts) ⇒ BlockMiddleware
Returns a new instance of BlockMiddleware.
6 7 8 9 10 11 12 |
# File 'lib/message_driver/middleware/block_middleware.rb', line 6 def initialize(destination, opts) super(destination) raise ArgumentError, 'you must provide at least one of :on_publish and :on_consume' \ unless opts.keys.any? { |k| [:on_publish, :on_consume].include? k } @on_publish_block = opts[:on_publish] @on_consume_block = opts[:on_consume] end |
Instance Attribute Details
#on_consume_block ⇒ Object (readonly)
Returns the value of attribute on_consume_block.
4 5 6 |
# File 'lib/message_driver/middleware/block_middleware.rb', line 4 def on_consume_block @on_consume_block end |
#on_publish_block ⇒ Object (readonly)
Returns the value of attribute on_publish_block.
4 5 6 |
# File 'lib/message_driver/middleware/block_middleware.rb', line 4 def on_publish_block @on_publish_block end |
Instance Method Details
#on_consume(body, headers, properties) ⇒ Object
18 19 20 |
# File 'lib/message_driver/middleware/block_middleware.rb', line 18 def on_consume(body, headers, properties) delegate_to_block(on_consume_block, body, headers, properties) end |
#on_publish(body, headers, properties) ⇒ Object
14 15 16 |
# File 'lib/message_driver/middleware/block_middleware.rb', line 14 def on_publish(body, headers, properties) delegate_to_block(on_publish_block, body, headers, properties) end |