Class | Sequel::MigrationReverser |
In: |
lib/sequel/extensions/pg_enum.rb
lib/sequel/extensions/migration.rb |
Parent: | Object |
Handles the reversing of reversible migrations. Basically records supported methods calls, translates them to reversed calls, and returns them in reverse order.
Reverse the actions for the given block. Takes the block given and returns a new block that reverses the actions taken by the given block.
# File lib/sequel/extensions/migration.rb, line 172 172: def reverse(&block) 173: begin 174: instance_exec(&block) 175: rescue 176: just_raise = true 177: end 178: if just_raise 179: Proc.new{raise Sequel::Error, 'irreversible migration method used, you may need to write your own down method'} 180: else 181: actions = @actions.reverse 182: Proc.new do 183: actions.each do |a| 184: pr = a.last.is_a?(Proc) ? a.pop : nil 185: # Allow calling private methods as the reversing methods are private 186: send(*a, &pr) 187: end 188: end 189: end 190: end