Sha256: 3d66c95a571b0302db8bf7abd9bf4c2eff13214b3b6006fab6a4cd0a72eb7a0c

Contents?: true

Size: 854 Bytes

Versions: 5

Compression:

Stored size: 854 Bytes

Contents

# frozen_string_literal: true

module Sidekiq
  module Throttled
    module Web
      module SummaryFix
        JAVASCRIPT = [File.read(__FILE__.sub(/\.rb$/, ".js")).freeze].freeze
        HEADERS    = { "Content-Type" => "application/javascript" }.freeze

        class << self
          attr_accessor :enabled

          def apply!(app)
            Sidekiq::WebAction.send(: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

5 entries across 5 versions & 1 rubygems

Version Path
sidekiq-throttled-0.11.0 lib/sidekiq/throttled/web/summary_fix.rb
sidekiq-throttled-0.10.0 lib/sidekiq/throttled/web/summary_fix.rb
sidekiq-throttled-0.10.0.beta lib/sidekiq/throttled/web/summary_fix.rb
sidekiq-throttled-0.10.0.alpha lib/sidekiq/throttled/web/summary_fix.rb
sidekiq-throttled-0.9.0 lib/sidekiq/throttled/web/summary_fix.rb