Class Sequel::MigrationReverser
In: lib/sequel/extensions/migration.rb
Parent: Sequel::BasicObject

Handles the reversing of reversible migrations. Basically records supported methods calls, translates them to reversed calls, and returns them in reverse order.

Methods

new   reverse  

Public Class methods

[Source]

     # File lib/sequel/extensions/migration.rb, line 157
157:     def initialize
158:       @actions = []
159:     end

Public Instance methods

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.

[Source]

     # File lib/sequel/extensions/migration.rb, line 164
164:     def reverse(&block)
165:       begin
166:         instance_eval(&block)
167:       rescue
168:         just_raise = true
169:       end
170:       if just_raise
171:         Proc.new{raise Sequel::Error, 'irreversible migration method used, you may need to write your own down method'}
172:       else
173:         actions = @actions.reverse
174:         Proc.new do
175:           actions.each do |a|
176:             if a.last.is_a?(Proc)
177:               pr = a.pop
178:               send(*a, &pr)
179:             else
180:               send(*a)
181:             end
182:           end
183:         end
184:       end
185:     end

[Validate]