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



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

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



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

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



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

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



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

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



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

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



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

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