Sha256: 57db77bfd74780ef1394f26f1280ed77c0b4b082b81d13ed2e3c75d342917ee9

Contents?: true

Size: 482 Bytes

Versions: 4

Compression:

Stored size: 482 Bytes

Contents

# frozen_string_literal: true

module Sidekiq
  module Throttled
    module Utils
      module_function

      # Resolve constant from it's name
      # @param name [#to_s] Constant name
      # @return [Object, nil] Resolved constant or nil if failed.
      def constantize(name)
        name.to_s.sub(/^::/, "").split("::").inject(Object, &:const_get)
      rescue NameError
        Sidekiq.logger.warn { "Failed to constantize: #{name}" }
        nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sidekiq-throttled-0.13.0 lib/sidekiq/throttled/utils.rb
sidekiq-throttled-0.12.0 lib/sidekiq/throttled/utils.rb
sidekiq-throttled-0.11.0 lib/sidekiq/throttled/utils.rb
sidekiq-throttled-0.10.0 lib/sidekiq/throttled/utils.rb