Sha256: a59e18b0e55162db0fc8838fee0d6e07c9abd95a9766a935654c309ae0aa23bd

Contents?: true

Size: 1.36 KB

Versions: 21

Compression:

Stored size: 1.36 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)
    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?
      begin
        @request.parameters
      rescue ActionController::BadRequest
        false
      end
    end
  end
end

Version data entries

21 entries across 19 versions & 5 rubygems

Version Path
actionpack-6.0.2.2 lib/action_dispatch/middleware/debug_view.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/debug_view.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/debug_view.rb
actionpack-6.0.2.1 lib/action_dispatch/middleware/debug_view.rb
actionpack-6.0.2 lib/action_dispatch/middleware/debug_view.rb
actionpack-6.0.2.rc2 lib/action_dispatch/middleware/debug_view.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/debug_view.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/actionpack-6.0.1/lib/action_dispatch/middleware/debug_view.rb
actionpack-6.0.2.rc1 lib/action_dispatch/middleware/debug_view.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/debug_view.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/actionpack-6.0.1/lib/action_dispatch/middleware/debug_view.rb
actionpack-6.0.1 lib/action_dispatch/middleware/debug_view.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/debug_view.rb
actionpack-6.0.1.rc1 lib/action_dispatch/middleware/debug_view.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/debug_view.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/debug_view.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/debug_view.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/debug_view.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/actionpack-6.0.0/lib/action_dispatch/middleware/debug_view.rb
actionpack-6.0.0 lib/action_dispatch/middleware/debug_view.rb