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, &block) ⇒ 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
39 40 41 42 43 |
# File 'lib/avromatic/model/builder.rb', line 39 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.
22 23 24 |
# File 'lib/avromatic/model/builder.rb', line 22 def config @config end |
#mod ⇒ Object (readonly)
Returns the value of attribute mod.
22 23 24 |
# File 'lib/avromatic/model/builder.rb', line 22 def mod @mod end |
Class Method Details
.model(**options, &block) ⇒ Object
For options see Avromatic::Model.build
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/avromatic/model/builder.rb', line 25 def self.model(**, &block) 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 class_eval(&block) if block end end |
Instance Method Details
#inclusions ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/avromatic/model/builder.rb', line 45 def inclusions [ Avromatic::Model::Configurable, Avromatic::Model::NestedModels, Avromatic::Model::Validation, Avromatic::Model::Attributes, Avromatic::Model::ValueObject, Avromatic::Model::RawSerialization, Avromatic::Model::MessagingSerialization ] end |