Class: DataMigrater::Migration
- Inherits:
-
Object
- Object
- DataMigrater::Migration
- Defined in:
- lib/data_migrater/migration.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(version, name, filename, path = "#{Rails.root}/db/data_migrate") ⇒ Migration
constructor
A new instance of Migration.
Constructor Details
#initialize(version, name, filename, path = "#{Rails.root}/db/data_migrate") ⇒ Migration
Returns a new instance of Migration.
7 8 9 10 11 12 |
# File 'lib/data_migrater/migration.rb', line 7 def initialize(version, name, filename, path = "#{Rails.root}/db/data_migrate") @filename = filename @name = name @path = path @version = version end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/data_migrater/migration.rb', line 5 def filename @filename end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/data_migrater/migration.rb', line 5 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/data_migrater/migration.rb', line 5 def version @version end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/data_migrater/migration.rb', line 14 def execute data_migration = DataMigration.new version: @version return false unless data_migration.valid? begin data_migration.save! migration.execute rescue StandardError => e data_migration.destroy raise e end end |