Class: RailsAsyncMigrations::Mutators::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_async_migrations/mutators/base.rb

Direct Known Subclasses

TriggerCallback, TurnAsync

Instance Method Summary collapse

Instance Method Details

#current_migrationObject



19
20
21
# File 'lib/rails_async_migrations/mutators/base.rb', line 19

def current_migration
  @current_migration ||= Connection::ActiveRecord.new(:up).current_migration
end

#fetch_from_fileObject



14
15
16
17
# File 'lib/rails_async_migrations/mutators/base.rb', line 14

def fetch_from_file
  require current_migration.filename
  current_migration.name.constantize
end

#migration_classObject

in some context we have to guess it from the file and current connection for instance when we use class methods such as turn_async



6
7
8
9
10
11
12
# File 'lib/rails_async_migrations/mutators/base.rb', line 6

def migration_class
  if instance.class == ActiveRecord::Migration
    fetch_from_file
  else
    instance.class
  end
end