Module: Cell::Ext::Migration::CommandRecorderFilter

Defined in:
lib/cell/ext/migration.rb

Overview

Patches to CommandRecorder, which let us roll back.

Instance Method Summary collapse

Instance Method Details

#add_command(command) ⇒ Object

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



174
175
176
# File 'lib/cell/ext/migration.rb', line 174

def add_command(command)
  @commands << [execute_ddl?, *command]
end

#commandsObject



165
166
167
168
169
170
171
# File 'lib/cell/ext/migration.rb', line 165

def commands
  @commands.select do |command|
    command[0]
  end.map do |command|
    [:force_call, [command[1], *command[2]], command[3]]
  end
end

#commands=Object

This maybe should’ve been attr_reader in CommandRecorder



160
161
162
163
# File 'lib/cell/ext/migration.rb', line 160

def commands=(*)
  # If this is actually used, we're fucked.
  fail "The problem with monkey patching is..."
end

#record(*command, &block) ⇒ Object

We override #record to proxy through add_command



179
180
181
182
183
184
185
# File 'lib/cell/ext/migration.rb', line 179

def record(*command, &block)
  if @reverting
    add_command inverse_of(*command, &block)
  else
    add_command (command << block)
  end
end