Class: ActiveRecord::Migration::CommandRecorder
- Inherits:
-
Object
- Object
- ActiveRecord::Migration::CommandRecorder
- Defined in:
- lib/active_record/migration/ext/command_recorder.rb
Instance Method Summary collapse
- #dup ⇒ Object
-
#inverse ⇒ Object
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.
Instance Method Details
#dup ⇒ Object
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 |
#inverse ⇒ Object
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 |