Class: OutboxGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Defined in:
lib/active_outbox/generators/outbox_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_migration_filesObject



10
11
12
13
14
15
16
17
# File 'lib/active_outbox/generators/outbox_generator.rb', line 10

def create_migration_files
  migration_path = "#{options['root_components_path']}/db/migrate"
  migration_template(
    "migration.rb",
    "#{migration_path}/outbox_create_#{table_name}.rb",
    migration_version: migration_version
  )
end

#json_typeObject



31
32
33
# File 'lib/active_outbox/generators/outbox_generator.rb', line 31

def json_type
  postgres? ? 'jsonb' : 'string'
end

#migration_versionObject



19
20
21
# File 'lib/active_outbox/generators/outbox_generator.rb', line 19

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

#postgres?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/active_outbox/generators/outbox_generator.rb', line 35

def postgres?
  ActiveRecord::Base.connection.adapter_name.downcase == 'postgresql'
end

#table_nameObject



23
24
25
# File 'lib/active_outbox/generators/outbox_generator.rb', line 23

def table_name
  "#{name}_outboxes"
end

#uuid_typeObject



27
28
29
# File 'lib/active_outbox/generators/outbox_generator.rb', line 27

def uuid_type
  postgres? ? 'uuid' : 'string'
end