Class: Ti::Generate::Model
- Inherits:
-
Object
- Object
- Ti::Generate::Model
show all
- Extended by:
- Utils
- Defined in:
- lib/ti/generate/model.rb
Class Method Summary
collapse
Methods included from Utils
append_to_router, base_location, create_directories, create_new_file, create_with_template, error, get_app_name, log, remove_directories, remove_files, templates, touch, underscore
Class Method Details
.create(name) ⇒ Object
7
8
9
|
# File 'lib/ti/generate/model.rb', line 7
def create(name)
create_model_file(name)
end
|
.create_model_file(name) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/ti/generate/model.rb', line 11
def create_model_file(name)
log "Creating a new model file named #{name}."
model_directory = "app/#{underscore(get_app_name)}/models"
create_directories(model_directory) unless File.directory?(model_directory)
create_directories("spec/models") unless File.directory?("spec/models")
create_new_file("#{model_directory}/#{name}.coffee")
create_new_file("spec/models/#{name}_spec.coffee", templates("specs/app_spec.coffee"))
append_to_router(name, 'models')
end
|