module Safrano::CoreIncl::String::Convert

Public Instance Methods

constantize() click to toggle source

thanks stackoverflow.com/questions/1448670/ruby-stringto-class

# File lib/core_ext/String/convert.rb, line 8
def constantize
  names = split('::')
  names.shift if names.empty? || names.first.empty?

  const = Object
  names.each do |name|
    const = if const.const_defined?(name)
              const.const_get(name)
            else
              const.const_missing(name)
            end
  end
  const
end