Class: DjiMqttConnect::Railties::MessageSerializer
- Inherits:
-
ActiveJob::Serializers::ObjectSerializer
- Object
- ActiveJob::Serializers::ObjectSerializer
- DjiMqttConnect::Railties::MessageSerializer
- Defined in:
- lib/dji_mqtt_connect/railties/message_serializer.rb
Instance Method Summary collapse
Instance Method Details
#deserialize(hash) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/dji_mqtt_connect/railties/message_serializer.rb', line 18 def deserialize(hash) # Rebuild the message, re-insert the data hash = hash["type"].constantize = hash["payload"].merge("_data" => {}) .new() end |
#serialize(message) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dji_mqtt_connect/railties/message_serializer.rb', line 6 def serialize() stringified_hash = .to_h.deep_stringify_keys # Strip the extra data element stringified_hash.delete("_data") super( "type" => .class.name, "payload" => stringified_hash ) end |