Class: Arfy::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/arfy/generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_migration_file(migration_name, dir) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/arfy/generator.rb', line 34

def generate_migration_file(migration_name, dir)
  migration_path = File.join(dir, new_migration_file_name_for(migration_name))
  File.open(migration_path, "w") do |file|
    file << code_for_migration(migration_name)
  end

  if migration_path
    puts "migration generated on: #{file}"
  else
    puts "FAIL. Migration not generated."
  end

  File.exists? migration_path
end