Module: UtilityBelt::Inflector

Defined in:
lib/utility_belt/print_methods.rb

Overview

extracted from ActiveSupport. will only add if not already available

Instance Method Summary collapse

Instance Method Details

#constantizeObject



76
77
78
79
80
81
82
83
84
85
# File 'lib/utility_belt/print_methods.rb', line 76

def constantize
  names = self.split('::')
  names.shift if names.empty? || names.first.empty?

  constant = Object
  names.each do |name|
    constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
  end
  constant
end