Class: ActiveRecord::Migration::CommandRecorder

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/migration/ext/command_recorder.rb

Instance Method Summary collapse

Instance Method Details

#dupObject



64
65
66
67
68
# File 'lib/active_record/migration/ext/command_recorder.rb', line 64

def dup
  CommandRecorder.new(delegate).tap do |recorder|
    recorder.commands = commands
  end
end

#inverseObject

Returns the inverse of these commands — the same as if they had been recorded with revert: each command is reverted and in the reverse order.



72
73
74
75
76
77
78
# File 'lib/active_record/migration/ext/command_recorder.rb', line 72

def inverse
  dup.tap do |recorder|
    recorder.commands = commands.reverse.map do |(command, args, _block)|
      inverse_of(command, args)
    end
  end
end