Methods

Class/Module Index [+]

Quicksearch

Sequel::MigrationReverser

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

Public Class Methods

new() click to toggle source
# File lib/sequel/extensions/migration.rb, line 157
def initialize
  @actions = []
end

Public Instance Methods

reverse(&block) click to toggle source

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 164
def reverse(&block)
  begin
    instance_eval(&block)
  rescue
    just_raise = true
  end
  if just_raise
    Proc.new{raise Sequel::Error, 'irreversible migration method used, you may need to write your own down method'}
  else
    actions = @actions.reverse
    Proc.new do
      actions.each do |a|
        if a.last.is_a?(Proc)
          pr = a.pop
          send(*a, &pr)
        else
          send(*a)
        end
      end
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.