Sha256: 75f8768813155d1120469b86e5dba7cf4181b80bcd62afcb2ed4a1e25f00aaca

Contents?: true

Size: 484 Bytes

Versions: 8

Compression:

Stored size: 484 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(%r{^::}, "").split("::").inject(Object, &:const_get)
      rescue NameError
        Sidekiq.logger.warn { "Failed to constantize: #{name}" }
        nil
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sidekiq-throttled-0.15.1 lib/sidekiq/throttled/utils.rb
sidekiq-throttled-0.18.0 lib/sidekiq/throttled/utils.rb
sidekiq-throttled-0.17.0 lib/sidekiq/throttled/utils.rb
sidekiq-throttled-0.16.2 lib/sidekiq/throttled/utils.rb
sidekiq-throttled-0.16.1 lib/sidekiq/throttled/utils.rb
sidekiq-throttled-0.16.0 lib/sidekiq/throttled/utils.rb
sidekiq-throttled-0.15.0 lib/sidekiq/throttled/utils.rb
sidekiq-throttled-0.14.1 lib/sidekiq/throttled/utils.rb