Class: Deimos::SchemaBackends::Mock

Inherits:
Base
  • Object
show all
Defined in:
lib/deimos/schema_backends/mock.rb

Overview

Mock implementation of a schema backend that does no encoding or validation.

Instance Attribute Summary

Attributes inherited from Base

#key_schema, #namespace, #schema

Instance Method Summary collapse

Methods inherited from Base

#coerce, content_type, #decode, #encode, field_type, #initialize, #load_schema, mock_backend, #sql_type

Constructor Details

This class inherits a constructor from Deimos::SchemaBackends::Base

Instance Method Details

#coerce_field(_field, value) ⇒ Object



27
28
29
# File 'lib/deimos/schema_backends/mock.rb', line 27

def coerce_field(_field, value)
  value
end

#decode_key(payload, key_id) ⇒ Object



37
38
39
# File 'lib/deimos/schema_backends/mock.rb', line 37

def decode_key(payload, key_id)
  payload[key_id]
end

#decode_payload(payload, schema:) ⇒ Object



8
9
10
# File 'lib/deimos/schema_backends/mock.rb', line 8

def decode_payload(payload, schema:)
  payload.is_a?(String) ? 'payload-decoded' : payload.map { |k, v| [k, "decoded-#{v}"] }
end

#encode_key(key_id, key, topic: nil) ⇒ Object



32
33
34
# File 'lib/deimos/schema_backends/mock.rb', line 32

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

#encode_payload(payload, schema:, topic: nil) ⇒ Object



13
14
15
# File 'lib/deimos/schema_backends/mock.rb', line 13

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

#schema_fieldsObject



22
23
24
# File 'lib/deimos/schema_backends/mock.rb', line 22

def schema_fields
  []
end

#validate(payload, schema:) ⇒ Object



18
19
# File 'lib/deimos/schema_backends/mock.rb', line 18

def validate(payload, schema:)
end