Sha256: b75d173be73c1a7ebad423cc60f94f7b75f48bf1f34ac93c3daf0c4594929d30

Contents?: true

Size: 436 Bytes

Versions: 3

Compression:

Stored size: 436 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]")
      end

      def serialize(message)
        message.as_json.to_json
      end

      def deserialize(message)
        JSON.parse(message)
      rescue StandardError => e
        @logger.error e
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
moleculer-0.2.0 lib/moleculer/serializers/json.rb
moleculer-0.1.1 lib/moleculer/serializers/json.rb
moleculer-0.1.0 lib/moleculer/serializers/json.rb