Class: Lepus::Producers::Definition
- Inherits:
-
Object
- Object
- Lepus::Producers::Definition
- Defined in:
- lib/lepus/producers/definition.rb
Overview
Definition class for producer-specific settings
Instance Attribute Summary collapse
-
#publish_options ⇒ Object
readonly
Returns the value of attribute publish_options.
Instance Method Summary collapse
- #exchange_name ⇒ Object
- #exchange_options ⇒ Object
-
#initialize(options = {}) ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize(options = {}) ⇒ Definition
Returns a new instance of Definition.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/lepus/producers/definition.rb', line 9 def initialize( = {}) opts = Lepus::Primitive::Hash.new().deep_symbolize_keys # Handle exchange configuration exchange_config = opts.delete(:exchange) || {} @exchange_options = Lepus::Publisher::DEFAULT_EXCHANGE_OPTIONS.merge(declaration_config(exchange_config)) # Handle default publish options @publish_options = Lepus::Publisher::DEFAULT_PUBLISH_OPTIONS.merge(opts.delete(:publish) || {}) # Store any remaining options for future use @options = opts end |
Instance Attribute Details
#publish_options ⇒ Object (readonly)
Returns the value of attribute publish_options.
7 8 9 |
# File 'lib/lepus/producers/definition.rb', line 7 def @publish_options end |
Instance Method Details
#exchange_name ⇒ Object
23 24 25 |
# File 'lib/lepus/producers/definition.rb', line 23 def exchange_name @exchange_options[:name] || raise(InvalidProducerConfigError, "Exchange name is required") end |
#exchange_options ⇒ Object
27 28 29 |
# File 'lib/lepus/producers/definition.rb', line 27 def @exchange_options.reject { |k, v| k == :name } end |