Method: MotionSupport::Inflector#deconstantize

Defined in:
motion/inflector/methods.rb

#deconstantize(path) ⇒ Object

Removes the rightmost segment from the constant expression in the string.

'Net::HTTP'.deconstantize   # => "Net"
'::Net::HTTP'.deconstantize # => "::Net"
'String'.deconstantize      # => ""
'::String'.deconstantize    # => ""
''.deconstantize            # => ""

See also demodulize.



166
167
168
# File 'motion/inflector/methods.rb', line 166

def deconstantize(path)
  path.to_s[0...(path.rindex('::') || 0)] # implementation based on the one in facets' Module#spacename
end