Sha256: 495e7be447ab0ea031f7100b660efecedca73d7817d6ec81749d9cb8a4c2f1fe

Contents?: true

Size: 862 Bytes

Versions: 8

Compression:

Stored size: 862 Bytes

Contents

# frozen_string_literal: true

module Sidekiq
  module Throttled
    module Web
      module SummaryFix
        JAVASCRIPT = [File.read(File.expand_path("summary_fix.js", __dir__)).freeze].freeze
        HEADERS    = { "Content-Type" => "application/javascript" }.freeze

        class << self
          attr_accessor :enabled

          def apply!(app)
            Sidekiq::WebAction.prepend SummaryFix

            app.get("/throttled/summary_fix") do
              [200, HEADERS.dup, JAVASCRIPT.dup]
            end
          end
        end

        def display_custom_head
          "#{super}#{summary_fix_script if SummaryFix.enabled}"
        end

        private

        def summary_fix_script
          src = "#{root_path}throttled/summary_fix"
          %(<script type="text/javascript" src="#{src}"></script>)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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