class Mongration::CreateMigration::MigrationFileWriter

@private

Public Class Methods

new(file_name, options = {}) click to toggle source
# File lib/mongration/create_migration/migration_file_writer.rb, line 11
def initialize(file_name, options = {})
  @file_name = file_name
  @up = options[:up]
  @down = options[:down]
end
write(file_name, options = {}) click to toggle source
# File lib/mongration/create_migration/migration_file_writer.rb, line 7
def self.write(file_name, options = {})
  new(file_name, options).write
end

Public Instance Methods

write() click to toggle source
# 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(<<EOS
class #{class_name}
  def self.up
    #{@up}
  end

  def self.down
    #{@down}
  end
end
EOS
          )
        end
        path
      end

Private Instance Methods

class_name() click to toggle source
# File lib/mongration/create_migration/migration_file_writer.rb, line 38
def class_name
  File.new(@file_name).class_name
end