Sha256: b0a82719a2f52c80ede325351f7a760251207a4233d42041950392b06d65d5e6

Contents?: true

Size: 977 Bytes

Versions: 10

Compression:

Stored size: 977 Bytes

Contents

# frozen_string_literal: true

module RailsSpotlight
  module Channels
    module Handlers
      class LogsHandler
        TYPE = 'logs'

        def initialize(data)
          @data = data
        end

        attr_reader :data

        def call
          return unless ::RailsSpotlight.config.live_console_enabled?
          return unless data['type'] == TYPE

          for_project = Array(data['project'])
          raise_project_mismatch_error!(for_project) if for_project.present? && !for_project.include?(project)

          { payload: data[:payload] }
        end

        def raise_project_mismatch_error!(for_project)
          raise ::RailsSpotlight::Channels::Handlers::ResponseError.new(
            "Project mismatch, Logs from #{for_project} project cannot be forwarded in #{project} project",
            code: :project_mismatch
          )
        end

        def project
          ::RailsSpotlight.config.project_name
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rails_spotlight-0.3.9 lib/rails_spotlight/channels/handlers/logs_handler.rb
rails_spotlight-0.3.8 lib/rails_spotlight/channels/handlers/logs_handler.rb
rails_spotlight-0.3.7 lib/rails_spotlight/channels/handlers/logs_handler.rb
rails_spotlight-0.3.6 lib/rails_spotlight/channels/handlers/logs_handler.rb
rails_spotlight-0.3.5 lib/rails_spotlight/channels/handlers/logs_handler.rb
rails_spotlight-0.3.4 lib/rails_spotlight/channels/handlers/logs_handler.rb
rails_spotlight-0.3.3 lib/rails_spotlight/channels/handlers/logs_handler.rb
rails_spotlight-0.3.2 lib/rails_spotlight/channels/handlers/logs_handler.rb
rails_spotlight-0.3.1 lib/rails_spotlight/channels/handlers/logs_handler.rb
rails_spotlight-0.3.0 lib/rails_spotlight/channels/handlers/logs_handler.rb