Class: DebugBar::RecipeBook::Default

Inherits:
Base
  • Object
show all
Defined in:
lib/debug-bar/recipe_book/default.rb

Overview

A default RecipeBook with recipes useful for Rails applications.

Instance Method Summary collapse

Methods inherited from Base

#include?, #recipe, #recipes, #template_search_paths, #template_search_paths=

Instance Method Details

#cookies_recipeObject

Displays the cookies.



29
30
31
# File 'lib/debug-bar/recipe_book/default.rb', line 29

def cookies_recipe
  return Proc.new {|b| ['Cookies', b[:cookies].awesome_print_html, {:id => 'cookies'}]}
end

#exception_recipeObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/debug-bar/recipe_book/default.rb', line 33

def exception_recipe
  return Proc.new do |b|
    exception = b.eval("request.env[\"action_dispatch.exception\"]")
    if exception
      [
        'Exception',
        exception.awesome_print_html + exception.backtrace.awesome_print_html,
        {:id => 'exceptions'}
      ]
    else
      nil
    end
  end
end

#host_recipeObject



48
49
50
51
52
53
# File 'lib/debug-bar/recipe_book/default.rb', line 48

def host_recipe
  return Proc.new do |b|
    host = Socket.gethostname
    ['Host', host.awesome_print_html, { id: 'host' }]
  end
end

#params_recipe(opts = {}) ⇒ Object

Displays params in a user readable fashion.

If the :cutoff option is given, it auto-hides when the params are more characters in length than the cutoff, otherwise it defaults to a sane length.



16
17
18
19
20
21
# File 'lib/debug-bar/recipe_book/default.rb', line 16

def params_recipe(opts={})
  return Proc.new do |b|
    params_s = b[:params].awesome_print_html
    ['Params', params_s, {:id => 'params'}]
  end
end

#session_recipeObject

Displays the session in a pretty printed way.



24
25
26
# File 'lib/debug-bar/recipe_book/default.rb', line 24

def session_recipe
  return Proc.new {|b| ['Session', b[:session].awesome_print_html, {:id => 'session'}]}
end