Class: Deimos::Generators::SchemaClassGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Deimos::Generators::SchemaClassGenerator
- Defined in:
- lib/generators/deimos/schema_class_generator.rb
Overview
Generator for Schema Classes used for the IDE and consumer/producer interfaces
Constant Summary collapse
- SPECIAL_TYPES =
%i(record enum).freeze
- INITIALIZE_WHITESPACE =
"\n#{' ' * 19}"
- IGNORE_DEFAULTS =
%w(message_id timestamp).freeze
- SCHEMA_CLASS_FILE =
'schema_class.rb'
- SCHEMA_RECORD_PATH =
File.('schema_class/templates/schema_record.rb.tt', __dir__).freeze
- SCHEMA_ENUM_PATH =
File.('schema_class/templates/schema_enum.rb.tt', __dir__).freeze
Instance Method Summary collapse
Instance Method Details
#generate ⇒ void
This method returns an undefined value.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/generators/deimos/schema_class_generator.rb', line 156 def generate _validate Rails.logger.info("Generating schemas from Deimos.config to #{Deimos.config.schema.generated_class_path}") found_schemas = Set.new Deimos.config.producer_objects.each do |config| schema_name = config.schema namespace = config.namespace || Deimos.config.producers.schema_namespace key_schema_name = config.key_config[:schema] found_schemas.add("#{namespace}.#{schema_name}") found_schemas.add("#{namespace}.#{key_schema_name}") if key_schema_name generate_classes(schema_name, namespace, config.key_config) end Deimos.config.consumer_objects.each do |config| schema_name = config.schema namespace = config.namespace key_schema_name = config.key_config[:schema] found_schemas.add("#{namespace}.#{schema_name}") found_schemas.add("#{namespace}.#{key_schema_name}") if key_schema_name generate_classes(schema_name, namespace, config.key_config) end generate_from_schema_files(found_schemas) end |