Class: AwsRecord::Generators::ModelGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/aws_record/model/model_generator.rb

Instance Attribute Summary

Attributes inherited from Base

#gsi_rw_units, #gsis, #length_validations, #primary_read_units, #primary_write_units, #required_attrs

Instance Method Summary collapse

Constructor Details

#initialize(args, *options) ⇒ ModelGenerator

Returns a new instance of ModelGenerator.



8
9
10
11
# File 'lib/generators/aws_record/model/model_generator.rb', line 8

def initialize(args, *options)
  self.class.source_root File.expand_path('templates', __dir__)
  super
end

Instance Method Details

#create_modelObject



13
14
15
# File 'lib/generators/aws_record/model/model_generator.rb', line 13

def create_model
  template 'model.erb', File.join('app/models', class_path, "#{file_name}.rb")
end

#create_table_configObject



17
18
19
20
21
22
# File 'lib/generators/aws_record/model/model_generator.rb', line 17

def create_table_config
  return unless options['table_config']

  template 'table_config.erb',
           File.join('db/table_config', class_path, "#{file_name}_config.rb")
end