Module: Avromatic::Model::FieldHelper
Instance Method Summary collapse
- #boolean?(field) ⇒ Boolean
- #nullable?(field) ⇒ Boolean
-
#optional?(field) ⇒ Boolean
An optional field is represented as a union where the first member is null.
- #required?(field) ⇒ Boolean
Instance Method Details
#boolean?(field) ⇒ Boolean
23 24 25 26 |
# File 'lib/avromatic/model/field_helper.rb', line 23 def boolean?(field) field.type.type_sym == :boolean || (optional?(field) && field.type.schemas.last.type_sym == :boolean) end |
#nullable?(field) ⇒ Boolean
19 20 21 |
# File 'lib/avromatic/model/field_helper.rb', line 19 def nullable?(field) optional?(field) || field.type.type_sym == :null end |
#optional?(field) ⇒ Boolean
An optional field is represented as a union where the first member is null.
10 11 12 13 |
# File 'lib/avromatic/model/field_helper.rb', line 10 def optional?(field) field.type.type_sym == :union && field.type.schemas.first.type_sym == :null end |
#required?(field) ⇒ Boolean
15 16 17 |
# File 'lib/avromatic/model/field_helper.rb', line 15 def required?(field) !optional?(field) end |