Module: Upgrow::Naming
Overview
Functions to derive constant names and other identifiers according to Upgrow’s conventions.
Instance Method Summary collapse
-
#model_to_record(model_name) ⇒ String
Convert a Model name to a Record name.
-
#record_to_model(record_name) ⇒ String
Convert a Record name to a Model name.
-
#repository_to_record(repository_name) ⇒ String
Convert a Repository name to a Record name.
Instance Method Details
#model_to_record(model_name) ⇒ String
Convert a Model name to a Record name. The Record name by convention is the Model name with a ‘Record` suffix.
15 16 17 |
# File 'lib/upgrow/naming.rb', line 15 def model_to_record(model_name) "#{model_name}Record" end |
#record_to_model(record_name) ⇒ String
Convert a Record name to a Model name. The Model name by convention is the Record name without the ‘Record` suffix.
25 26 27 |
# File 'lib/upgrow/naming.rb', line 25 def record_to_model(record_name) record_name.delete_suffix('Record') end |
#repository_to_record(repository_name) ⇒ String
Convert a Repository name to a Record name. The Record name is inferred by the Repository name without the ‘Repository` suffix, and with the `Record` suffix added.
36 37 38 |
# File 'lib/upgrow/naming.rb', line 36 def repository_to_record(repository_name) "#{repository_name.delete_suffix("Repository")}Record" end |