Module: AMQP::Boilerplate::Producer
- Defined in:
- lib/amqp/boilerplate/producer.rb
Overview
Use this module to turn a class into a potential producer that can deliver messages to an AMQP exchange.
You turn your class into a producer by extending the module and call the required macros #amqp and #amqp_message methods.
To specify exchange options you can call the optional macro #amqp_exchange method.
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
-
#amqp(opts = {}) ⇒ void
Macro that sets up amqp for a class.
-
#amqp_boilerplate_exchange ⇒ Object
TODO Can we do this in a nicer way?.
-
#amqp_boilerplate_message ⇒ Object
TODO Can we do this in a nicer way?.
-
#amqp_boilerplate_options ⇒ Object
TODO Can we do this in a nicer way?.
-
#amqp_exchange(type = :direct, name = AMQ::Protocol::EMPTY_STRING, opts = {}) ⇒ void
Configuration for the exchange to be used.
-
#amqp_message(method_name) ⇒ void
Choose the method that will return the actual message (payload) to be delivered to the exchange.
Instance Method Details
#amqp(opts = {}) ⇒ void
This method returns an undefined value.
Macro that sets up amqp for a class.
40 41 42 43 |
# File 'lib/amqp/boilerplate/producer.rb', line 40 def amqp(opts={}) send :include, InstanceMethods @amqp_boilerplate_options = opts end |
#amqp_boilerplate_exchange ⇒ Object
TODO Can we do this in a nicer way?
81 82 83 |
# File 'lib/amqp/boilerplate/producer.rb', line 81 def amqp_boilerplate_exchange @amqp_boilerplate_exchange || amqp_exchange end |
#amqp_boilerplate_message ⇒ Object
TODO Can we do this in a nicer way?
86 87 88 |
# File 'lib/amqp/boilerplate/producer.rb', line 86 def @amqp_boilerplate_message end |
#amqp_boilerplate_options ⇒ Object
TODO Can we do this in a nicer way?
76 77 78 |
# File 'lib/amqp/boilerplate/producer.rb', line 76 def @amqp_boilerplate_options end |
#amqp_exchange(type = :direct, name = AMQ::Protocol::EMPTY_STRING, opts = {}) ⇒ void
This method returns an undefined value.
Configuration for the exchange to be used
54 55 56 |
# File 'lib/amqp/boilerplate/producer.rb', line 54 def amqp_exchange(type=:direct, name=AMQ::Protocol::EMPTY_STRING, opts={}) @amqp_boilerplate_exchange = [type, name, opts] end |
#amqp_message(method_name) ⇒ void
This method returns an undefined value.
Choose the method that will return the actual message (payload) to be delivered to the exchange
This method SHOULD return a string.
71 72 73 |
# File 'lib/amqp/boilerplate/producer.rb', line 71 def (method_name) @amqp_boilerplate_message = method_name end |