Class: Merb::Generators::MigrationGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/generators/migration.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generator

#go_up, #initialize, #with_modules

Methods included from ColorfulMessages

#error, #success, #warning

Constructor Details

This class inherits a constructor from Merb::Generators::Generator

Class Method Details

.source_rootObject



5
6
7
# File 'lib/generators/migration.rb', line 5

def self.source_root
  File.join(super, 'component', 'migration')
end

Instance Method Details

#class_nameObject



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

def class_name
  "#{self.name.camel_case}Migration"
end

#file_nameObject



31
32
33
# File 'lib/generators/migration.rb', line 31

def file_name
  "#{version}_#{migration_name}_migration"
end

#migration_nameObject



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

def migration_name
  self.name.snake_case
end

#table_nameObject



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

def table_name
  self.name.snake_case.pluralize
end

#versionObject



35
36
37
38
39
# File 'lib/generators/migration.rb', line 35

def version
  # TODO: handle ActiveRecord timestamped migrations
  n = options[:delete] ? current_migration_nr : current_migration_nr + 1
  format("%03d", n)
end