Method: Alman::Util.constantize

Defined in:
lib/alman/apibits/util.rb

.constantize(str, prefix = false) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/alman/apibits/util.rb', line 36

def self.constantize(str, prefix=false)
  str = str.to_s
  begin
    str.split('::').reduce(Alman, :const_get)
  rescue NameError => e
    if prefix
      raise e
    else
      p = "#{self.name}".split("::").first
      constantize("#{p}::#{str}", true)
    end
  end
end