Sha256: 88f28e58c31eeb72905802056f943220956beec1e7d942969a515b392567d89d

Contents?: true

Size: 847 Bytes

Versions: 2

Compression:

Stored size: 847 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.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

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-throttled-0.13.0 lib/sidekiq/throttled/web/summary_fix.rb
sidekiq-throttled-0.12.0 lib/sidekiq/throttled/web/summary_fix.rb