Class: DjiMqttConnect::Sys::Product::StatusMarshal

Inherits:
MessageMarshal show all
Includes:
Utils::MessageParsing
Defined in:
lib/dji_mqtt_connect/marshals/sys/product/status_marshal.rb

Defined Under Namespace

Classes: AttributeTransformer

Instance Method Summary collapse

Methods inherited from MessageMarshal

#dump

Instance Method Details

#load(raw_message) ⇒ Object

Attempts to look a the method attribute, and builds a specific Message class for the message



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dji_mqtt_connect/marshals/sys/product/status_marshal.rb', line 22

def load(raw_message)
  # Parse the message from JSON
  parsed_message = parse_json(raw_message)

  # Transform the message
  transformed_message = attribute_transformer.call(parsed_message)
  message_method = transformed_message["_method"]

  # Build an instance of the class, or a generic message from the current class
  message_class = message_class_from_message_method(message_method, StatusMessage)
  build_message(message_class, transformed_message)
end