Class: Mqttopia::Subscriptions::Services::TestDebug

Inherits:
Base
  • Object
show all
Defined in:
lib/mqttopia/subscriptions/services/test_debug.rb

Defined Under Namespace

Classes: TestDebugInvalidError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::DataExtractor

#extract_trip_id, #extract_user_id

Constructor Details

#initialize(topic_name:, payload:, options: {}) ⇒ TestDebug

Returns a new instance of TestDebug.



18
19
20
21
22
# File 'lib/mqttopia/subscriptions/services/test_debug.rb', line 18

def initialize(topic_name:, payload:, options: {})
  @topic_name = topic_name
  @payload = payload
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



13
14
15
# File 'lib/mqttopia/subscriptions/services/test_debug.rb', line 13

def options
  @options
end

#payloadObject (readonly)

Returns the value of attribute payload.



13
14
15
# File 'lib/mqttopia/subscriptions/services/test_debug.rb', line 13

def payload
  @payload
end

#topic_nameObject (readonly)

Returns the value of attribute topic_name.



13
14
15
# File 'lib/mqttopia/subscriptions/services/test_debug.rb', line 13

def topic_name
  @topic_name
end

Class Method Details

.call(topic, payload, options = {}) ⇒ Object



24
25
26
# File 'lib/mqttopia/subscriptions/services/test_debug.rb', line 24

def self.call(topic, payload, options = {})
  new(topic_name: topic, payload: payload, options: options).process
end

Instance Method Details

#processObject



28
29
30
31
32
33
34
35
# File 'lib/mqttopia/subscriptions/services/test_debug.rb', line 28

def process
  raise TestDebugInvalidError, errors.full_messages.to_sentence unless valid?

  Mqttopia::Serializers::TestDebug.serialize({
                                               topic_name: topic_name,
                                               payload: payload
                                             })
end