Sha256: 507504c0bec85d70191199c854f89a4b16c210f42d2cfbafab24858120c3dbe3

Contents?: true

Size: 466 Bytes

Versions: 1

Compression:

Stored size: 466 Bytes

Contents

require "json"

module Moleculer
  module Serializers
    ##
    # Serializes data packets to and from JSON
    class Json
      def initialize(config)
        @logger = config.logger.get_child("[SERIALIZER]")
        @config = config
      end

      def serialize(message)
        message.to_h.to_json
      end

      def deserialize(message)
        JSON.parse(message)
      rescue StandardError => e
        @config.handle_error(e)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
moleculer-0.3.0 lib/moleculer/serializers/json.rb