Module: Resque::Plugins::ResqueUUID::Util

Extended by:
Util
Included in:
Util
Defined in:
lib/resque/plugins/resque_uuid/util.rb

Instance Method Summary collapse

Instance Method Details

#constantize(camel_cased_word) ⇒ Object

:nodoc:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/resque/plugins/resque_uuid/util.rb', line 28

def constantize(camel_cased_word)
  camel_cased_word = camel_cased_word.to_s

  if camel_cased_word.include?('-')
    camel_cased_word = classify(camel_cased_word)
  end

  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