module Dolarblue::Inflector

Public Instance Methods

demodulize(path) click to toggle source

Removes the module part from the expression in the string.

@param path [String] the module expression stringified

@example

demodulize('ActiveRecord::CoreExtensions::String::Inflections') # => "Inflections"
demodulize('Inflections')                                       # => "Inflections"

@return [String] with the module part removed and the stringified class name only

# File lib/dolarblue/inflector.rb, line 14
def demodulize(path)
  path = path.to_s
  if i = path.rindex('::')
    path[(i+2)..-1]
  else
    path
  end
end