Sha256: e36403995d1416fb493887d75925638222835f6be63f47211ae7239bc99687e0

Contents?: true

Size: 907 Bytes

Versions: 4

Compression:

Stored size: 907 Bytes

Contents

module RailsLiveDashboard
  module Subscribers
    class ActionControllerSubscriber
      def initialize
        ActiveSupport::Notifications.subscribe 'start_processing.action_controller' do |_event|
          RailsLiveDashboard::Context.instance.start
        end

        ActiveSupport::Notifications.subscribe 'process_action.action_controller' do |event|
          next if event.payload[:controller].include?('RailsLiveDashboard')

          handle_event(event)
        rescue StandardError => e
          Rails.logger.error "Error on handle action controller event: #{e.message}"
        end
      end

      private

      def handle_event(event)
        Recorders::RequestRecorder.new(event).execute
        Recorders::ExceptionRecorder.new(event.payload[:exception_object]).execute if event.payload[:exception_object]

        RailsLiveDashboard::Context.instance.reset
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_live_dashboard-0.2.0 lib/rails_live_dashboard/subscribers/action_controller_subscriber.rb
rails_live_dashboard-0.1.2 lib/rails_live_dashboard/subscribers/action_controller_subscriber.rb
rails_live_dashboard-0.1.1 lib/rails_live_dashboard/subscribers/action_controller_subscriber.rb
rails_live_dashboard-0.1.0 lib/rails_live_dashboard/subscribers/action_controller_subscriber.rb