Class: String

Inherits:
Object show all
Defined in:
lib/name-spotter/monkey_patches.rb

Instance Method Summary collapse

Instance Method Details

#constantizeObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/name-spotter/monkey_patches.rb', line 9

def constantize()
  camel_cased_word = self
  names = camel_cased_word.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