Class: Tasks::DatabaseMigrationScaffolderTask
- Inherits:
-
Rake::Task
- Object
- Rake::Task
- Tasks::DatabaseMigrationScaffolderTask
- Defined in:
- lib/db_migration_scaffolder.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#database ⇒ Object
Returns the value of attribute database.
-
#format ⇒ Object
Returns the value of attribute format.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #as_date! ⇒ Object
- #execute(args = nil) ⇒ Object
- #initializer(name = :create_db_migration, taskmanager = nil) {|_self| ... } ⇒ Object
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
7 8 9 |
# File 'lib/db_migration_scaffolder.rb', line 7 def content @content end |
#database ⇒ Object
Returns the value of attribute database.
7 8 9 |
# File 'lib/db_migration_scaffolder.rb', line 7 def database @database end |
#format ⇒ Object
Returns the value of attribute format.
7 8 9 |
# File 'lib/db_migration_scaffolder.rb', line 7 def format @format end |
#name ⇒ Object
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
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 |