Class: ActionDispatch::DebugView

Inherits:
ActionView::Base
  • Object
show all
Defined in:
lib/action_dispatch/middleware/debug_view.rb

Overview

:nodoc:

Constant Summary collapse

RESCUES_TEMPLATE_PATH =
File.expand_path("templates", __dir__)

Instance Method Summary collapse

Constructor Details

#initialize(assigns) ⇒ DebugView

Returns a new instance of DebugView.



12
13
14
15
16
# File 'lib/action_dispatch/middleware/debug_view.rb', line 12

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

Instance Method Details

#compiled_method_containerObject



18
19
20
# File 'lib/action_dispatch/middleware/debug_view.rb', line 18

def compiled_method_container
  self.class
end

#debug_hash(object) ⇒ Object



42
43
44
# File 'lib/action_dispatch/middleware/debug_view.rb', line 42

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

#debug_headers(headers) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/action_dispatch/middleware/debug_view.rb', line 34

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

#debug_params(params) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/action_dispatch/middleware/debug_view.rb', line 22

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

#params_valid?Boolean

Returns:

  • (Boolean)


60
61
62
63
64
# File 'lib/action_dispatch/middleware/debug_view.rb', line 60

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

#protect_against_forgery?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/action_dispatch/middleware/debug_view.rb', line 56

def protect_against_forgery?
  false
end

#renderObject



46
47
48
49
50
51
52
53
54
# File 'lib/action_dispatch/middleware/debug_view.rb', line 46

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

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