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

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

Instance Method Summary collapse

Instance Method Details

#current_migration_number(dirname) ⇒ Object

:nodoc:


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

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

#migration_exists?(dirname, file_name) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)

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

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

#migration_lookup_at(dirname) ⇒ Object

:nodoc:


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

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

#next_migration_number(dirname) ⇒ Object

:nodoc:

Raises:

  • (NotImplementedError)

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

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