Module: Rails::Generators::Migration::ClassMethods

Defined in:
lib/rails/generators/migration.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#current_migration_number(dirname) ⇒ Object



22
23
24
25
26
# File 'lib/rails/generators/migration.rb', line 22

def current_migration_number(dirname)
  migration_lookup_at(dirname).collect do |file|
    File.basename(file).split("_").first.to_i
  end.max.to_i
end

#migration_exists?(dirname, file_name) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rails/generators/migration.rb', line 18

def migration_exists?(dirname, file_name)
  migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first
end

#migration_lookup_at(dirname) ⇒ Object



14
15
16
# File 'lib/rails/generators/migration.rb', line 14

def migration_lookup_at(dirname)
  Dir.glob("#{dirname}/[0-9]*_*.rb")
end

#next_migration_number(dirname) ⇒ Object

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/rails/generators/migration.rb', line 28

def next_migration_number(dirname)
  raise NotImplementedError
end