Sha256: 6c0e4030a44cf170fd8ddb1c4d691fa7bdb64fbdefe57c699d21d1c768543eec

Contents?: true

Size: 1.49 KB

Versions: 16

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

require "pp"

require "action_view"
require "action_view/base"

module ActionDispatch
  class DebugView < ActionView::Base # :nodoc:
    RESCUES_TEMPLATE_PATHS = [File.expand_path("templates", __dir__)]

    def initialize(assigns)
      paths = RESCUES_TEMPLATE_PATHS.dup
      lookup_context = ActionView::LookupContext.new(paths)
      super(lookup_context, assigns, nil)
      @exception_wrapper = assigns[:exception_wrapper]
    end

    def compiled_method_container
      self.class
    end

    def error_highlight_available?
      @exception_wrapper.error_highlight_available?
    end

    def debug_params(params)
      clean_params = params.clone
      clean_params.delete("action")
      clean_params.delete("controller")

      if clean_params.empty?
        "None"
      else
        PP.pp(clean_params, +"", 200)
      end
    end

    def debug_headers(headers)
      if headers.present?
        headers.inspect.gsub(",", ",\n")
      else
        "None"
      end
    end

    def debug_hash(object)
      object.to_hash.sort_by { |k, _| k.to_s }.map { |k, v| "#{k}: #{v.inspect rescue $!.message}" }.join("\n")
    end

    def render(*)
      logger = ActionView::Base.logger

      if logger && logger.respond_to?(:silence)
        logger.silence { super }
      else
        super
      end
    end

    def protect_against_forgery?
      false
    end

    def params_valid?
      @request.parameters
    rescue ActionController::BadRequest
      false
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
actionpack-7.1.5 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.4.2 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.4.1 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.4 lib/action_dispatch/middleware/debug_view.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actionpack-7.1.3.4/lib/action_dispatch/middleware/debug_view.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/actionpack-7.1.3.4/lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.3.4 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.3.2 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.3.1 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.3 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.2 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.1 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.0 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.0.rc2 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.0.rc1 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.1.0.beta1 lib/action_dispatch/middleware/debug_view.rb