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 149
149:     def initialize
150:       @actions = []
151:     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 156
156:     def reverse(&block)
157:       begin
158:         instance_eval(&block)
159:       rescue
160:         just_raise = true
161:       end
162:       if just_raise
163:         Proc.new{raise Sequel::Error, 'irreversible migration method used, you may need to write your own down method'}
164:       else
165:         actions = @actions.reverse
166:         Proc.new do
167:           actions.each do |a|
168:             if a.last.is_a?(Proc)
169:               pr = a.pop
170:               send(*a, &pr)
171:             else
172:               send(*a)
173:             end
174:           end
175:         end
176:       end
177:     end

[Validate]