Class: Avromatic::Model::Builder
- Inherits:
-
Object
- Object
- Avromatic::Model::Builder
- Defined in:
- lib/avromatic/model/builder.rb
Overview
This class implements generating models from Avro schemas.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#mod ⇒ Object
readonly
Returns the value of attribute mod.
Class Method Summary collapse
-
.model(**options) ⇒ Object
For options see Avromatic::Model.build.
Instance Method Summary collapse
- #inclusions ⇒ Object
-
#initialize(**options) ⇒ Builder
constructor
For options see Avromatic::Model.build.
Constructor Details
#initialize(**options) ⇒ Builder
For options see Avromatic::Model.build
36 37 38 39 40 |
# File 'lib/avromatic/model/builder.rb', line 36 def initialize(**) @mod = Module.new @config = Avromatic::Model::Configuration.new(**) define_included_method end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
21 22 23 |
# File 'lib/avromatic/model/builder.rb', line 21 def config @config end |
#mod ⇒ Object (readonly)
Returns the value of attribute mod.
21 22 23 |
# File 'lib/avromatic/model/builder.rb', line 21 def mod @mod end |
Class Method Details
.model(**options) ⇒ Object
For options see Avromatic::Model.build
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/avromatic/model/builder.rb', line 24 def self.model(**) Class.new do include Avromatic::Model::Builder.new(**).mod # Name is required for attribute validations on an anonymous class. def self.name super || (@name ||= config.avro_schema.name.classify) end end end |
Instance Method Details
#inclusions ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/avromatic/model/builder.rb', line 42 def inclusions [ ActiveModel::Validations, Virtus.value_object, Avromatic::Model::Configurable, Avromatic::Model::NestedModels, Avromatic::Model::Validation, Avromatic::Model::Attributes, Avromatic::Model::ValueObject, Avromatic::Model::RawSerialization, Avromatic::Model::MessagingSerialization ] end |