Module: Injectable::Inflector
- Defined in:
- lib/injectable/inflector.rb
Overview
Used so we don’t need active support around to perform inflections.
Class Method Summary collapse
-
.underscore(string) ⇒ String
Underscore a string.
Class Method Details
.underscore(string) ⇒ String
Underscore a string. This is partially taken from Active Support, but dumbed down for our purposes - we don’t handle namespacing.
22 23 24 25 26 27 |
# File 'lib/injectable/inflector.rb', line 22 def underscore(string) value = string.dup value.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') value.gsub!(/([a-z\d])([A-Z])/, '\1_\2') value.downcase! end |