Class: MinceMigrator::Deleter
- Inherits:
-
Object
- Object
- MinceMigrator::Deleter
- Defined in:
- lib/mince_migrator/deleter.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#migration ⇒ Object
readonly
Returns the value of attribute migration.
-
#migration_name ⇒ Object
readonly
Returns the value of attribute migration_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #can_delete_migration? ⇒ Boolean
- #delete_migration ⇒ Object
-
#initialize(options) ⇒ Deleter
constructor
A new instance of Deleter.
- #migration_path ⇒ Object
- #ran_migration ⇒ Object
- #reasons_for_failure ⇒ Object
Constructor Details
#initialize(options) ⇒ Deleter
Returns a new instance of Deleter.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mince_migrator/deleter.rb', line 10 def initialize() if [:migration] @migration = [:migration] @migration_name = Migrations::Name.new(migration.name) elsif [:name] @migration_name = Migrations::Name.new([:name]) end @name = migration_name.value @filename = migration_name.filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
8 9 10 |
# File 'lib/mince_migrator/deleter.rb', line 8 def filename @filename end |
#migration ⇒ Object (readonly)
Returns the value of attribute migration.
8 9 10 |
# File 'lib/mince_migrator/deleter.rb', line 8 def migration @migration end |
#migration_name ⇒ Object (readonly)
Returns the value of attribute migration_name.
8 9 10 |
# File 'lib/mince_migrator/deleter.rb', line 8 def migration_name @migration_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/mince_migrator/deleter.rb', line 8 def name @name end |
Instance Method Details
#can_delete_migration? ⇒ Boolean
26 27 28 |
# File 'lib/mince_migrator/deleter.rb', line 26 def can_delete_migration? ::File.exists?(migration_path) end |
#delete_migration ⇒ Object
21 22 23 24 |
# File 'lib/mince_migrator/deleter.rb', line 21 def delete_migration ::FileUtils.rm(migration_path) ran_migration.delete if ran_migration end |
#migration_path ⇒ Object
34 35 36 |
# File 'lib/mince_migrator/deleter.rb', line 34 def migration_path ::File.join Config.migration_dir, filename end |
#ran_migration ⇒ Object
38 39 40 |
# File 'lib/mince_migrator/deleter.rb', line 38 def ran_migration @ran_migration ||= RanMigration.find_by_name(name) end |
#reasons_for_failure ⇒ Object
30 31 32 |
# File 'lib/mince_migrator/deleter.rb', line 30 def reasons_for_failure "Migration does not exist with name '#{name}'" unless can_delete_migration? end |