Sha256: 717a15c1f5e58ac450a24e9fe0c93deb71819e665a9d62a50cb00801ec697c39
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module Upgrow # Functions to derive constant names and other identifiers according to # Upgrow's conventions. module Naming extend self # Convert a Model name to a Record name. The Record name by convention is # the Model name with a `Record` suffix. # # @param model_name [String] the Model name. # # @return [String] the Record name. def model_to_record(model_name) "#{model_name}Record" end # Convert a Record name to a Model name. The Model name by convention is the # Record name without the `Record` suffix. # # @param record_name [String] the Record name. # # @return [String] the Model name. def record_to_model(record_name) record_name.delete_suffix('Record') end # 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. # # @param repository_name [String] the Repository name. # # @return [String] the Record name. def repository_to_record(repository_name) "#{repository_name.delete_suffix("Repository")}Record" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
upgrow-0.0.5 | lib/upgrow/naming.rb |