Sha256: b58520d9806a5010d62cfb61b832633a2ea6ef0c254d9c1d2bc10176014a9701

Contents?: true

Size: 494 Bytes

Versions: 10

Compression:

Stored size: 494 Bytes

Contents

# frozen_string_literal: true

require_relative 'avro_base'

module Deimos
  module SchemaBackends
    # Leave Ruby hashes as is but validate them against the schema.
    # Useful for unit tests.
    class AvroValidation < AvroBase
      # @override
      def decode_payload(payload, schema: nil)
        JSON.parse(payload)
      end

      # @override
      def encode_payload(payload, schema: nil, topic: nil)
        payload.to_h.with_indifferent_access.to_json
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
deimos-ruby-2.0.0.pre.beta3 lib/deimos/schema_backends/avro_validation.rb
deimos-ruby-2.0.0.pre.beta2 lib/deimos/schema_backends/avro_validation.rb
deimos-ruby-2.0.0.pre.beta1 lib/deimos/schema_backends/avro_validation.rb
deimos-ruby-2.0.0.pre.alpha7 lib/deimos/schema_backends/avro_validation.rb
deimos-ruby-2.0.0.pre.alpha6 lib/deimos/schema_backends/avro_validation.rb
deimos-ruby-2.0.0.pre.alpha5 lib/deimos/schema_backends/avro_validation.rb
deimos-ruby-2.0.0.pre.alpha4 lib/deimos/schema_backends/avro_validation.rb
deimos-ruby-2.0.0.pre.alpha3 lib/deimos/schema_backends/avro_validation.rb
deimos-ruby-2.0.0.pre.alpha2 lib/deimos/schema_backends/avro_validation.rb
deimos-ruby-2.0.0.pre.alpha1 lib/deimos/schema_backends/avro_validation.rb