Sha256: 24db2590b04b3f9f05cb0f042e58a39f5b382de8c87c4efcd4afc6df81ebaa0d

Contents?: true

Size: 1.33 KB

Versions: 75

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require "pp"

require "action_view"
require "action_view/base"

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

    def initialize(assigns)
      paths = [RESCUES_TEMPLATE_PATH]
      lookup_context = ActionView::LookupContext.new(paths)
      super(lookup_context, assigns, nil)
    end

    def compiled_method_container
      self.class
    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

75 entries across 71 versions & 6 rubygems

Version Path
actionpack-7.0.3 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.0.2.4 lib/action_dispatch/middleware/debug_view.rb
actionpack-6.1.5.1 lib/action_dispatch/middleware/debug_view.rb
actionpack-6.1.5 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.0.2.3 lib/action_dispatch/middleware/debug_view.rb
actionpack-6.1.4.7 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.0.2.2 lib/action_dispatch/middleware/debug_view.rb
actionpack-6.1.4.6 lib/action_dispatch/middleware/debug_view.rb
actionpack-6.1.4.5 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.0.2.1 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.0.2 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.0.1 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.0.0 lib/action_dispatch/middleware/debug_view.rb
actionpack-6.1.4.4 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.0.0.rc3 lib/action_dispatch/middleware/debug_view.rb
actionpack-6.1.4.3 lib/action_dispatch/middleware/debug_view.rb
actionpack-6.1.4.2 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.0.0.rc2 lib/action_dispatch/middleware/debug_view.rb
actionpack-7.0.0.rc1 lib/action_dispatch/middleware/debug_view.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/actionpack-6.1.4.1/lib/action_dispatch/middleware/debug_view.rb