Class: Mqttopia::Subscriptions::Redirect
- Inherits:
-
Object
- Object
- Mqttopia::Subscriptions::Redirect
- Defined in:
- lib/mqttopia/subscriptions/redirect.rb
Instance Attribute Summary collapse
-
#debugging ⇒ Object
readonly
Returns the value of attribute debugging.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#topic_name ⇒ Object
readonly
Returns the value of attribute topic_name.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(topic_name:, payload:) ⇒ Redirect
constructor
A new instance of Redirect.
Constructor Details
#initialize(topic_name:, payload:) ⇒ Redirect
16 17 18 19 20 |
# File 'lib/mqttopia/subscriptions/redirect.rb', line 16 def initialize(topic_name:, payload:) @topic_name = topic_name @payload = payload @debugging = Mqttopia.debugging end |
Instance Attribute Details
#debugging ⇒ Object (readonly)
Returns the value of attribute debugging.
14 15 16 |
# File 'lib/mqttopia/subscriptions/redirect.rb', line 14 def debugging @debugging end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
14 15 16 |
# File 'lib/mqttopia/subscriptions/redirect.rb', line 14 def payload @payload end |
#topic_name ⇒ Object (readonly)
Returns the value of attribute topic_name.
14 15 16 |
# File 'lib/mqttopia/subscriptions/redirect.rb', line 14 def topic_name @topic_name end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mqttopia/subscriptions/redirect.rb', line 22 def call Mqttopia::Topics::Services::KEYS.each do |key, value| next unless topic_name.match?(value[:regex]) return { event: key&.to_s, data: value[:service].safe_constantize.call( topic_name, payload, { serializer: value[:serializer] } ) } end Mqttopia::Logger.warn "No matching topic found for #{topic_name}" if debugging end |