Module: Avromatic::Model::RawSerialization::Encode

Extended by:
ActiveSupport::Concern
Included in:
Avromatic::Model::RawSerialization
Defined in:
lib/avromatic/model/raw_serialization.rb

Constant Summary collapse

UNSPECIFIED =
Object.new

Instance Method Summary collapse

Instance Method Details

#avro_key_datum(validate: UNSPECIFIED) ⇒ Object



77
78
79
80
81
82
83
# File 'lib/avromatic/model/raw_serialization.rb', line 77

def avro_key_datum(validate: UNSPECIFIED)
  unless validate == UNSPECIFIED
    ActiveSupport::Deprecation.warn("The 'validate' argument to #{__method__} is deprecated.")
  end

  avro_hash(key_avro_field_references, strict: true)
end

#avro_raw_key(validate: UNSPECIFIED) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/avromatic/model/raw_serialization.rb', line 35

def avro_raw_key(validate: UNSPECIFIED)
  unless validate == UNSPECIFIED
    ActiveSupport::Deprecation.warn("The 'validate' argument to #{__method__} is deprecated.")
  end

  raise 'Model has no key schema' unless key_avro_schema

  avro_raw_encode(key_attributes_for_avro, :key)
end

#avro_raw_value(validate: UNSPECIFIED) ⇒ Object

rubocop:enable Style/AccessModifierDeclarations



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/avromatic/model/raw_serialization.rb', line 23

def avro_raw_value(validate: UNSPECIFIED)
  unless validate == UNSPECIFIED
    ActiveSupport::Deprecation.warn("The 'validate' argument to #{__method__} is deprecated.")
  end

  if self.class.recursively_immutable?
    @avro_raw_value ||= avro_raw_encode(value_attributes_for_avro, :value)
  else
    avro_raw_encode(value_attributes_for_avro, :value)
  end
end

#avro_value_datum(validate: UNSPECIFIED) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/avromatic/model/raw_serialization.rb', line 65

def avro_value_datum(validate: UNSPECIFIED)
  unless validate == UNSPECIFIED
    ActiveSupport::Deprecation.warn("The 'validate' argument to #{__method__} is deprecated.")
  end

  if self.class.recursively_immutable?
    @avro_value_datum ||= avro_hash(value_avro_field_references, strict: true)
  else
    avro_hash(value_avro_field_references, strict: true)
  end
end

#key_attributes_for_avro(validate: UNSPECIFIED) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/avromatic/model/raw_serialization.rb', line 57

def key_attributes_for_avro(validate: UNSPECIFIED)
  unless validate == UNSPECIFIED
    ActiveSupport::Deprecation.warn("The 'validate' argument to #{__method__} is deprecated.")
  end

  avro_hash(key_avro_field_references)
end

#value_attributes_for_avro(validate: UNSPECIFIED) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/avromatic/model/raw_serialization.rb', line 45

def value_attributes_for_avro(validate: UNSPECIFIED)
  unless validate == UNSPECIFIED
    ActiveSupport::Deprecation.warn("The 'validate' argument to #{__method__} is deprecated.")
  end

  if self.class.recursively_immutable?
    @value_attributes_for_avro ||= avro_hash(value_avro_field_references)
  else
    avro_hash(value_avro_field_references)
  end
end