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