class Mongration::Migrate::Direction

Public Class Methods

new(files) click to toggle source
# File lib/mongration/migrate/direction.rb, line 5
def initialize(files)
  @files = files
end

Public Instance Methods

perform() click to toggle source
# File lib/mongration/migrate/direction.rb, line 9
def perform
  @files.each do |file|
    file.load

    summarize(description_for(file)) do
      migrate(file)
    end

    persist(file)
  end
end

Private Instance Methods

description_for(file) click to toggle source
# File lib/mongration/migrate/direction.rb, line 37
def description_for(file)
  "#{file.version} #{file.class_name}"
end
summarize(description) { || ... } click to toggle source
# File lib/mongration/migrate/direction.rb, line 23
def summarize(description)
  Mongration.out.puts("#{description}: #{before_text}")

  begin
    yield
  rescue => e
    Mongration.out.puts("#{e.inspect}: An error has occured, this and all later migrations cancelled")
    raise e
  end

  Mongration.out.puts("#{description}: #{after_text}")
  Mongration.out.puts
end