Module: StrongMigrations::Migration

Defined in:
lib/strong_migrations/migration.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/strong_migrations/migration.rb', line 9

def method_missing(method, *args)
  return super if is_a?(ActiveRecord::Schema)

  strong_migrations_checker.perform(method, *args) do
    super
  end
end

Instance Method Details

#migrate(direction) ⇒ Object



3
4
5
6
7
# File 'lib/strong_migrations/migration.rb', line 3

def migrate(direction)
  strong_migrations_checker.direction = direction
  super
  connection.begin_db_transaction if strong_migrations_checker.transaction_disabled
end

#safety_assuredObject



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

def safety_assured
  strong_migrations_checker.safety_assured do
    yield
  end
end

#stop!(message, header: "Custom check") ⇒ Object



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

def stop!(message, header: "Custom check")
  raise StrongMigrations::UnsafeMigration, "\n=== #{header} #strong_migrations ===\n\n#{message}\n"
end