Class: ActiveOutbox::Generators::ModelGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
AdapterHelper, Rails::Generators::Migration
Defined in:
lib/generators/active_outbox/model/model_generator.rb

Instance Method Summary collapse

Methods included from AdapterHelper

json_type, mysql?, postgres?, uuid_type

Instance Method Details

#aggregate_identifier_typeObject



52
53
54
# File 'lib/generators/active_outbox/model/model_generator.rb', line 52

def aggregate_identifier_type
  options['uuid'].present? ? ActiveOutbox::AdapterHelper.uuid_type : 'integer'
end

#create_migration_fileObject



31
32
33
34
35
36
37
38
# File 'lib/generators/active_outbox/model/model_generator.rb', line 31

def create_migration_file
  migration_path = "#{root_path}/db/migrate"
  migration_template(
    'migration.rb',
    "#{migration_path}/active_outbox_create_#{table_name}.rb",
    migration_version: migration_version
  )
end

#migration_versionObject



44
45
46
# File 'lib/generators/active_outbox/model/model_generator.rb', line 44

def migration_version
  "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end

#root_pathObject



40
41
42
# File 'lib/generators/active_outbox/model/model_generator.rb', line 40

def root_path
  options['component_path'] || Rails.root
end

#table_nameObject



48
49
50
# File 'lib/generators/active_outbox/model/model_generator.rb', line 48

def table_name
  model_name.blank? ? 'outboxes' : "#{model_name}_outboxes"
end