Module: Que::Utils::Constantization

Included in:
Que
Defined in:
lib/que/utils/constantization.rb

Instance Method Summary collapse

Instance Method Details

#constantize(string) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/que/utils/constantization.rb', line 6

def constantize(string)
  Que.assert String, string

  if string.respond_to?(:constantize)
    string.constantize
  else
    names = string.split('::')
    names.reject!(&:empty?)
    names.inject(Object, &:const_get)
  end
end