Sha256: 2b696d2264cfb2a11fab225f394475780534a5f3764808683a6ae91e5fa34725

Contents?: true

Size: 975 Bytes

Versions: 29

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

module PagesCore
  module ProcessTitler
    extend ActiveSupport::Concern

    included do
      before_action :set_process_title
      after_action :unset_process_title
    end

    class << self
      attr_writer :number_of_requests

      def original_title
        @original_title ||= $PROGRAM_NAME
      end

      def inc_number_of_requests
        @number_of_requests ||= 0
        @number_of_requests += 1
        yield @number_of_requests
      end

      def number_of_requests
        @number_of_requests ||= 0
      end
    end

    protected

    def set_process_title
      PagesCore::ProcessTitler.inc_number_of_requests do |i|
        $0 = PagesCore::ProcessTitler.original_title +
             ": Handling #{request.path} (#{i} reqs)"
      end
    end

    def unset_process_title
      $0 = PagesCore::ProcessTitler.original_title +
           ": Idle (#{PagesCore::ProcessTitler.number_of_requests} reqs)"
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
pages_core-3.15.5 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.15.4 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.15.3 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.15.2 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.15.1 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.14.0 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.13.0 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.12.7 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.12.6 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.12.5 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.12.4 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.12.3 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.12.2 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.12.1 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.12.0 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.11.3 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.11.2 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.11.1 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.11.0 app/controllers/concerns/pages_core/process_titler.rb
pages_core-3.10.2 app/controllers/concerns/pages_core/process_titler.rb