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
8
9
10
11
12
13
14
|
# File 'lib/pliny/commands/generator/model.rb', line 8
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
16
17
18
19
20
21
22
|
# File 'lib/pliny/commands/generator/model.rb', line 16
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
24
25
26
27
28
29
|
# File 'lib/pliny/commands/generator/model.rb', line 24
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
|