Sha256: df771b44eec50185a3e7ad2d6b7e6f5fbbc0bdd4a44ce5d3b9dbd3f57de204f0

Contents?: true

Size: 940 Bytes

Versions: 34

Compression:

Stored size: 940 Bytes

Contents

# frozen_string_literal: true

module Deimos
  module SchemaBackends
    # Mock implementation of a schema backend that does no encoding or validation.
    class Mock < Base
      # @override
      def decode_payload(payload, schema:)
        payload.is_a?(String) ? 'payload-decoded' : payload.map { |k, v| [k, "decoded-#{v}"] }
      end

      # @override
      def encode_payload(payload, schema:, topic: nil)
        payload.is_a?(String) ? 'payload-encoded' : payload.map { |k, v| [k, "encoded-#{v}"] }
      end

      # @override
      def validate(payload, schema:)
      end

      # @override
      def schema_fields
        []
      end

      # @override
      def coerce_field(_field, value)
        value
      end

      # @override
      def encode_key(key_id, key, topic: nil)
        { key_id => key }
      end

      # @override
      def decode_key(payload, key_id)
        payload[key_id]
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
deimos-ruby-1.24.2 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.24.1 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.24.0 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.23.3 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.23.2 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.23.1.pre.beta6 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.23.1.pre.beta5 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.23.1.pre.beta4 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.23.1.pre.beta3 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.23.1.pre.beta2 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.23.1.pre.beta1 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.23.0 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.22.5 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.22.4 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.22.3 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.22.2 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.22.1 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.22 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.20.1 lib/deimos/schema_backends/mock.rb
deimos-ruby-1.20.0 lib/deimos/schema_backends/mock.rb