Module: Generator::Naming
- Defined in:
- lib/generator/support/naming.rb
Overview
Centralized naming conventions for generated code Handles class names, attribute names, and acronym transformations
Class Method Summary collapse
-
.attribute_name(prop_name, prop_def = nil) ⇒ String
Convert a property name to a Ruby attribute name - Underscores the name - Strips "is_" prefix from boolean attributes for idiomatic Ruby.
-
.class_name(name) ⇒ String
Convert a string to a Ruby class name with proper acronym handling.
Class Method Details
.attribute_name(prop_name, prop_def = nil) ⇒ String
Convert a property name to a Ruby attribute name
- Underscores the name
- Strips "is_" prefix from boolean attributes for idiomatic Ruby
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/generator/support/naming.rb', line 22 def attribute_name(prop_name, prop_def = nil) underscored = prop_name.underscore return underscored unless prop_def # Strip is_ prefix from boolean attributes for more idiomatic Ruby if prop_def["type"] == "boolean" || prop_def["type"] == "bool" underscored.sub(/^is_/, "") else underscored end end |