Class: Mongration::CreateMigration::MigrationFileWriter
- Inherits:
-
Object
- Object
- Mongration::CreateMigration::MigrationFileWriter
- Defined in:
- lib/mongration/create_migration/migration_file_writer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file_name, options = {}) ⇒ MigrationFileWriter
constructor
A new instance of MigrationFileWriter.
- #write ⇒ Object
Constructor Details
#initialize(file_name, options = {}) ⇒ MigrationFileWriter
Returns a new instance of MigrationFileWriter.
11 12 13 14 15 |
# File 'lib/mongration/create_migration/migration_file_writer.rb', line 11 def initialize(file_name, = {}) @file_name = file_name @up = [:up] @down = [:down] end |
Class Method Details
.write(file_name, options = {}) ⇒ Object
7 8 9 |
# File 'lib/mongration/create_migration/migration_file_writer.rb', line 7 def self.write(file_name, = {}) new(file_name, ).write end |
Instance Method Details
#write ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mongration/create_migration/migration_file_writer.rb', line 17 def write path = ::File.join(Mongration.configuration.dir, @file_name) ::File.open(path, 'w') do |file| file.write("class \#{class_name}\n def self.up\n \#{@up}\n end\n\n def self.down\n \#{@down}\n end\nend\n" ) end path end |