class MinceMigrator::Reverter
Attributes
migration_name[R]
name[R]
Public Class Methods
new(options)
click to toggle source
# File lib/mince_migrator/reverter.rb, line 9 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 @errors = [] end
Public Instance Methods
can_revert_migration?()
click to toggle source
# File lib/mince_migrator/reverter.rb, line 20 def can_revert_migration? @errors = [] validate_migration validate_ran_migration @errors.empty? end
migration()
click to toggle source
# File lib/mince_migrator/reverter.rb, line 45 def migration @migration ||= Migration.find(name) end
migration_not_ran?()
click to toggle source
# File lib/mince_migrator/reverter.rb, line 49 def migration_not_ran? migration && !migration.ran? end
ran_migration()
click to toggle source
# File lib/mince_migrator/reverter.rb, line 53 def ran_migration migration.ran_migration if migration end
reasons_for_failure()
click to toggle source
# File lib/mince_migrator/reverter.rb, line 41 def reasons_for_failure @errors.join ", " end
revert_migration()
click to toggle source
# File lib/mince_migrator/reverter.rb, line 35 def revert_migration migration.revert ran_migration.delete true end
validate_migration()
click to toggle source
# File lib/mince_migrator/reverter.rb, line 31 def validate_migration @errors << "Migration does not exist with name '#{name}'" if migration.nil? end
validate_ran_migration()
click to toggle source
# File lib/mince_migrator/reverter.rb, line 27 def validate_ran_migration @errors << "Migration has not ran" if migration_not_ran? end