Method: ActiveSupport::Inflector#deconstantize
- Defined in:
- lib/active_support/inflector/methods.rb
#deconstantize(path) ⇒ Object
Removes the rightmost segment from the constant expression in the string:
"Net::HTTP".deconstantize # => "Net"
"::Net::HTTP".deconstantize # => "::Net"
"String".deconstantize # => ""
"::String".deconstantize # => ""
"".deconstantize # => ""
See also demodulize
.
177 178 179 |
# File 'lib/active_support/inflector/methods.rb', line 177 def deconstantize(path) path.to_s[0...(path.rindex('::') || 0)] # implementation based on the one in facets' Module#spacename end |