module ActiveSupport::Inflector
def deconstantize(path)
deconstantize('') # => ""
deconstantize('::String') # => ""
deconstantize('String') # => ""
deconstantize('::Net::HTTP') # => "::Net"
deconstantize('Net::HTTP') # => "Net"
Removes the rightmost segment from the constant expression in the string.
def deconstantize(path) path.to_s[0, path.rindex("::") || 0] # implementation based on the one in facets' Module#spacename end