Class: ExceptionHandler::MigrationGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_errors_migrationObject

> Create



31
32
33
# File 'lib/generators/exception_handler/migration_generator.rb', line 31

def create_errors_migration
  migration_template "migration.rb.erb", "db/migrate/create_#{table_name.to_s.gsub("_","")}.rb", migration_version: migration_version
end

#migration_versionObject

> Migration Version



46
47
48
49
50
# File 'lib/generators/exception_handler/migration_generator.rb', line 46

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

#rails5?Boolean

> Rails 5?

Returns:

  • (Boolean)


41
42
43
# File 'lib/generators/exception_handler/migration_generator.rb', line 41

def rails5?
  Rails.version.start_with? '5'
end

#table_nameObject

> Table Name - false = off, true = errors, value = value

> Always outputs string for some reason…



24
25
26
# File 'lib/generators/exception_handler/migration_generator.rb', line 24

def table_name
  ExceptionHandler.config.db
end