Class: PluginMigrator::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/plugin_migrator/migration.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Migration

Returns a new instance of Migration.



4
5
6
7
8
# File 'lib/plugin_migrator/migration.rb', line 4

def initialize(args)
  @args = args
  @version = args[:version]
  @version_helper = args[:version_helper]
end

Instance Method Details

#instanceObject



10
11
12
13
# File 'lib/plugin_migrator/migration.rb', line 10

def instance
  require @args[:path]
  @instance ||= @args[:class_name].constantize.new
end

#migrate!Object



19
20
21
22
# File 'lib/plugin_migrator/migration.rb', line 19

def migrate!
  instance.migrate(:up)
  @version_helper.add_version(@version)
end

#migrated?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/plugin_migrator/migration.rb', line 15

def migrated?
  @version_helper.version_exists?(@version)
end

#rollback!Object



24
25
26
27
# File 'lib/plugin_migrator/migration.rb', line 24

def rollback!
  instance.migrate(:down)
  @version_helper.remove_version(@version)
end