Class: AnnotateRb::ModelAnnotator::FileNameResolver
- Inherits:
-
Object
- Object
- AnnotateRb::ModelAnnotator::FileNameResolver
- Defined in:
- lib/annotate_rb/model_annotator/file_name_resolver.rb
Class Method Summary collapse
Class Method Details
.call(filename_template, model_name, table_name) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/annotate_rb/model_annotator/file_name_resolver.rb', line 7 def call(filename_template, model_name, table_name) # e.g. with a model file name like "app/models/collapsed/example/test_model.rb" # and using a collapsed `model_name` such as "collapsed/test_model" model_name_without_namespace = model_name.split("/").last filename_template .gsub("%MODEL_NAME%", model_name) .gsub("%MODEL_NAME_WITHOUT_NS%", model_name_without_namespace) .gsub("%PLURALIZED_MODEL_NAME%", model_name.pluralize) .gsub("%TABLE_NAME%", table_name || model_name.pluralize) end |