Module: Sidekiq::Util

Defined in:
lib/sidekiq-sqs/util.rb

Instance Method Summary collapse

Instance Method Details

#constantize(string) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sidekiq-sqs/util.rb', line 5

def constantize(string)
  # Try just requiring the files first
  
  begin
    string.constantize
  rescue LoadError => ex
    begin
      require string.split("::").map(&:underscore).join("/")
      string.constantize
    rescue LoadError => ex
      STDERR.puts("Error loading constant: #{string}. #{ex.message}")
      STDERR.puts(ex.backtrace.join("\n"))
      raise ex
    end
  end
end