class MinceMigrator::Deleter

Attributes

filename[R]
migration[R]
migration_name[R]
name[R]

Public Class Methods

new(options) click to toggle source
# File lib/mince_migrator/deleter.rb, line 10
def initialize(options)
  if options[:migration]
    @migration = options[:migration]
    @migration_name = Migrations::Name.new(migration.name)
  elsif options[:name]
    @migration_name = Migrations::Name.new(options[:name])
  end
  @name = migration_name.value
  @filename = migration_name.filename
end

Public Instance Methods

can_delete_migration?() click to toggle source
# File lib/mince_migrator/deleter.rb, line 26
def can_delete_migration?
  ::File.exists?(migration_path)
end
delete_migration() click to toggle source
# File lib/mince_migrator/deleter.rb, line 21
def delete_migration
  ::FileUtils.rm(migration_path)
  ran_migration.delete if ran_migration
end
migration_path() click to toggle source
# File lib/mince_migrator/deleter.rb, line 34
def migration_path
  ::File.join Config.migration_dir, filename
end
ran_migration() click to toggle source
# File lib/mince_migrator/deleter.rb, line 38
def ran_migration
  @ran_migration ||= RanMigration.find_by_name(name)
end
reasons_for_failure() click to toggle source
# File lib/mince_migrator/deleter.rb, line 30
def reasons_for_failure
  "Migration does not exist with name '#{name}'" unless can_delete_migration?
end