Sha256: ef36e1d7d3e3533d860b38ec40d9c5a3e918f2d02493704a5812444938bf0d7f

Contents?: true

Size: 931 Bytes

Versions: 13

Compression:

Stored size: 931 Bytes

Contents

# frozen_string_literal: true

require_relative '../../rails_command_executor'
module RailsSpotlight
  module Middlewares
    module Handlers
      class ConsoleActionHandler < BaseActionHandler
        def execute
          RailsSpotlight.config.logger && RailsSpotlight.config.logger.info("Executing command: #{command}") # rubocop:disable Style/SafeNavigation
          executor.execute(command)
        end

        private

        def executor
          @executor ||= ::RailsSpotlight::RailsCommandExecutor.new
        end

        def inspect_types
          @inspect_types ||= body_fetch('inspect_types')
        end

        def command
          @command ||= body_fetch('command')
        end

        def json_response_body
          return executor.result_as_json unless executor.execution_successful?

          { result: executor.result_as_json(inspect_types: inspect_types) }
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rails_spotlight-0.4.2 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.4.1 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.4.0 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.3.9 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.3.8 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.3.7 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.3.6 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.3.5 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.3.4 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.3.3 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.3.2 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.3.1 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb
rails_spotlight-0.3.0 lib/rails_spotlight/middlewares/handlers/console_action_handler.rb