Class: Ardb::Runner::GenerateCommand::MigrationCommand
- Inherits:
-
Object
- Object
- Ardb::Runner::GenerateCommand::MigrationCommand
- Defined in:
- lib/ardb/runner/generate_command.rb
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
-
#initialize(identifier) ⇒ MigrationCommand
constructor
A new instance of MigrationCommand.
- #run ⇒ Object
Constructor Details
#initialize(identifier) ⇒ MigrationCommand
Returns a new instance of MigrationCommand.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ardb/runner/generate_command.rb', line 38 def initialize(identifier) if identifier.nil? raise Ardb::Runner::CmdError, "specify a name for the migration" end @identifier = identifier @class_name = @identifier.classify.pluralize @file_name = begin "#{Time.now.strftime("%Y%m%d%H%M%S")}_#{@identifier.underscore}" end @template = "require 'ardb/migration_helpers'\n\n"\ "class #{@class_name} < ActiveRecord::Migration\n"\ " include Ardb::MigrationHelpers\n\n"\ " def change\n"\ " end\n\n"\ "end\n" end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
36 37 38 |
# File 'lib/ardb/runner/generate_command.rb', line 36 def class_name @class_name end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
36 37 38 |
# File 'lib/ardb/runner/generate_command.rb', line 36 def file_name @file_name end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
36 37 38 |
# File 'lib/ardb/runner/generate_command.rb', line 36 def identifier @identifier end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
36 37 38 |
# File 'lib/ardb/runner/generate_command.rb', line 36 def template @template end |