Method: ActiveSupport::Inflector#deconstantize

Defined in:
activesupport/lib/active_support/inflector/methods.rb

#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.

[View source]

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