Class: Tasks::DatabaseMigrationScaffolderTask

Inherits:
Rake::Task
  • Object
show all
Defined in:
lib/db_migration_scaffolder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content.



7
8
9
# File 'lib/db_migration_scaffolder.rb', line 7

def content
  @content
end

#databaseObject

Returns the value of attribute database.



7
8
9
# File 'lib/db_migration_scaffolder.rb', line 7

def database
  @database
end

#formatObject

Returns the value of attribute format.



7
8
9
# File 'lib/db_migration_scaffolder.rb', line 7

def format
  @format
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/db_migration_scaffolder.rb', line 7

def name
  @name
end

Instance Method Details

#as_date!Object



39
40
41
# File 'lib/db_migration_scaffolder.rb', line 39

def as_date!
  @date = true
end

#execute(args = nil) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/db_migration_scaffolder.rb', line 14

def execute(args=nil)
  super(args)
  raise "Need to provide a database and name to create a migration on" unless database && name

  filename = sprintf(format, database, next_migration_number, name)
  puts ">>> Creating migration in #{filename} <<<"
  File.open(filename, 'w') { |f| f.write(content) }
end

#initializer(name = :create_db_migration, taskmanager = nil) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



9
10
11
12
# File 'lib/db_migration_scaffolder.rb', line 9

def initializer(name=:create_db_migration, taskmanager=nil)
  super(name, taskmanager)
  yield self if block_given?
end