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

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) current_migration_number(dirname)

:nodoc:



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

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

- (Boolean) migration_exists?(dirname, file_name)

:nodoc:

Returns:

  • (Boolean)


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

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

- (Object) migration_lookup_at(dirname)

:nodoc:



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

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

- (Object) next_migration_number(dirname)

:nodoc:

Raises:

  • (NotImplementedError)


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

def next_migration_number(dirname) #:nodoc:
  raise NotImplementedError
end