Class: Deimos::Generators::SchemaClassGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
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.expand_path('schema_class/templates/schema_record.rb.tt', __dir__).freeze
SCHEMA_ENUM_PATH =
File.expand_path('schema_class/templates/schema_enum.rb.tt', __dir__).freeze

Instance Method Summary collapse

Instance Method Details

#generateObject

:nodoc:



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/generators/deimos/schema_class_generator.rb', line 100

def generate
  _validate
  Rails.logger.info("Generating schemas from Deimos.config to #{Deimos.config.schema.generated_class_path}")
  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]
    generate_classes(schema_name, namespace, key_schema_name)
  end

  Deimos.config.consumer_objects.each do |config|
    schema_name = config.schema
    namespace = config.namespace
    key_schema_name = config.key_config[:schema]
    generate_classes(schema_name, namespace, key_schema_name)
  end
end