Class: Msgr::Route
- Inherits:
-
Object
- Object
- Msgr::Route
- Defined in:
- lib/msgr/route.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#consumer ⇒ Object
readonly
Returns the value of attribute consumer.
-
#key ⇒ Object
(also: #routing_key)
readonly
Returns the value of attribute key.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(key, opts = {}) ⇒ Route
constructor
A new instance of Route.
- #name ⇒ Object
Constructor Details
#initialize(key, opts = {}) ⇒ Route
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/msgr/route.rb', line 7 def initialize(key, opts = {}) @key = key.to_s @opts = opts raise ArgumentError.new 'Routing key required.' unless @key.present? raise ArgumentError.new 'Missing `to` options.' unless @opts[:to] if (match = /\A(?<consumer>\w+)#(?<action>\w+)\z/.match(opts[:to].strip.to_s)) @consumer = "#{match[:consumer].camelize}Consumer" @action = match[:action].underscore else raise ArgumentError.new "Invalid consumer format: #{opts[:to].strip.to_s.inspect}. Must be `consumer_class#action`." end end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
4 5 6 |
# File 'lib/msgr/route.rb', line 4 def action @action end |
#consumer ⇒ Object (readonly)
Returns the value of attribute consumer.
4 5 6 |
# File 'lib/msgr/route.rb', line 4 def consumer @consumer end |
#key ⇒ Object (readonly) Also known as: routing_key
Returns the value of attribute key.
4 5 6 |
# File 'lib/msgr/route.rb', line 4 def key @key end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
4 5 6 |
# File 'lib/msgr/route.rb', line 4 def opts @opts end |
Instance Method Details
#name ⇒ Object
22 23 24 |
# File 'lib/msgr/route.rb', line 22 def name "msgr.consumer-#{key}//#{consumer}##{action}" end |