module Cell::Ext::Migration::CommandRecorderFilter

Patches to CommandRecorder, which let us roll back.

Public Instance Methods

add_command(command) click to toggle source

saves the state of a recorded command with the context it was in.

# File lib/cell/ext/migration.rb, line 173
def add_command(command)
  @commands << [execute_ddl?, *command]
end
commands() click to toggle source
# File lib/cell/ext/migration.rb, line 164
def commands
  @commands.select do |command|
    command[0]
  end.map do |command|
    [:force_call, [command[1], *command[2]], command[3]]
  end
end
commands=(*) click to toggle source

This maybe should've been attr_reader in CommandRecorder

# File lib/cell/ext/migration.rb, line 159
def commands=(*)
  # If this is actually used, we're fucked.
  fail "The problem with monkey patching is..."
end
record(*command, &block) click to toggle source

We override record to proxy through add_command

# File lib/cell/ext/migration.rb, line 178
def record(*command, &block)
  if @reverting
    add_command inverse_of(*command, &block)
  else
    add_command (command << block)
  end
end