Class: Pliny::Commands::Generator::Model
- Inherits:
-
Base
- Object
- Base
- Pliny::Commands::Generator::Model
show all
- Defined in:
- lib/pliny/commands/generator/model.rb
Instance Attribute Summary
Attributes inherited from Base
#name, #options, #stream
Instance Method Summary
collapse
Methods inherited from Base
#display, #field_name, #initialize, #plural_class_name, #pluralized_file_name, #render_template, #singular_class_name, #table_name, #write_file, #write_template
Instance Method Details
#create ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/pliny/commands/generator/model.rb', line 6
def create
model = "./lib/models/#{field_name}.rb"
write_template('model.erb', model,
singular_class_name: singular_class_name,
paranoid: options[:paranoid])
display "created model file #{model}"
end
|
#create_migration ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/pliny/commands/generator/model.rb', line 14
def create_migration
migration = "./db/migrate/#{Time.now.to_i}_create_#{table_name}.rb"
write_template('model_migration.erb', migration,
table_name: table_name,
paranoid: options[:paranoid])
display "created migration #{migration}"
end
|
#create_test ⇒ Object
22
23
24
25
26
27
|
# File 'lib/pliny/commands/generator/model.rb', line 22
def create_test
test = "./spec/models/#{field_name}_spec.rb"
write_template('model_test.erb', test,
singular_class_name: singular_class_name)
display "created test #{test}"
end
|