module ActiveSupport::Inflector
def deconstantize(path)
''.deconstantize # => ""
'::String'.deconstantize # => ""
'String'.deconstantize # => ""
'::Net::HTTP'.deconstantize # => "::Net"
'Net::HTTP'.deconstantize # => "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