Class: Effective::Generators::MigrationGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Helpers
Defined in:
lib/generators/effective/migration_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_migration ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/effective/migration_generator.rb', line 24

def create_migration
  if invoked_attributes.present?
    Rails::Generators.invoke('migration', ["create_#{plural_name}"] + (invokable(invoked_attributes) | timestamps))
  elsif resource.klass_attributes.present?
    raise 'klass_attributes already exist.  We cant migrate (yet). Exiting.'
  elsif resource.written_attributes.present?
    Rails::Generators.invoke('migration', ["create_#{plural_name}"] + invokable(resource.belong_tos_attributes) + (invokable(resource.written_attributes) | timestamps))
  else
    raise 'You need to specify some attributes or have a model file present'
  end
end

#invoke_migration ⇒ Object



20
21
22
# File 'lib/generators/effective/migration_generator.rb', line 20

def invoke_migration
  say_status :invoke, :migration, :white
end