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
32 33 34 35 36 |
# File 'lib/avromatic/model/builder.rb', line 32 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.
17 18 19 |
# File 'lib/avromatic/model/builder.rb', line 17 def config @config end |
#mod ⇒ Object (readonly)
Returns the value of attribute mod.
17 18 19 |
# File 'lib/avromatic/model/builder.rb', line 17 def mod @mod end |
Class Method Details
.model(**options) ⇒ Object
For options see Avromatic::Model.build
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/avromatic/model/builder.rb', line 20 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
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/avromatic/model/builder.rb', line 38 def inclusions [ ActiveModel::Validations, Virtus.value_object, Avromatic::Model::Configurable, Avromatic::Model::Attributes, Avromatic::Model::ValueObject, Avromatic::Model::RawSerialization, Avromatic::Model::MessagingSerialization ] end |