Class: Stager::ModelGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/stager/model/model_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_migrationObject



31
32
33
34
35
# File 'lib/generators/stager/model/model_generator.rb', line 31

def create_migration
  unless options[:skip_migration]
    migration_template 'migration.rb', "db/migrate/create_#{model_path.pluralize.gsub('/', '_')}.rb"
  end
end

#create_modelObject



24
25
26
27
28
29
# File 'lib/generators/stager/model/model_generator.rb', line 24

def create_model
  template 'model.rb', "app/models/#{model_path}.rb"
    
  template "spec/model.rb", "spec/models/#{model_path}_spec.rb"
  template 'spec/fixtures.yml', "spec/fixtures/#{model_path.pluralize}.yml"
end

#set_optionsObject



16
17
18
19
20
21
22
# File 'lib/generators/stager/model/model_generator.rb', line 16

def set_options
  @model_attributes = []
  
  model_args.each do |arg|
    @model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
  end
end