Sha256: a51666abb1727b34faa6a1a9a9fa7035dbad37b95c79a5902600eaf2e7ede833
Contents?: true
Size: 793 Bytes
Versions: 30
Compression:
Stored size: 793 Bytes
Contents
# frozen_string_literal: true require "dry-transformer" require "json" module DjiMqttConnect module Thing::Product class ServicesMarshal < MessageMarshal # Renames the method attribute class HashTransformer < Dry::Transformer::Pipe import Dry::Transformer::HashTransformations define! do rename_keys _method: :method end end # Converts a message for transmission via MQTT def dump(message) # Fix up the hash representation transformed_message = hash_transformer.call(message) # Convert the transformed message into JSON JSON.generate(transformed_message) end private def hash_transformer @hash_transformer ||= HashTransformer.new end end end end
Version data entries
30 entries across 30 versions & 1 rubygems