Class: Rack::Bug::CachePanel::PanelApp

Inherits:
PanelApp
  • Object
show all
Defined in:
lib/rack/bug/panels/cache_panel/panel_app.rb

Instance Attribute Summary

Attributes inherited from PanelApp

#request

Instance Method Summary collapse

Methods inherited from PanelApp

#call, #not_found, #params, #render_template, #validate_params

Methods included from Render

#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params

Instance Method Details

#delete_cacheObject



25
26
27
28
29
30
# File 'lib/rack/bug/panels/cache_panel/panel_app.rb', line 25

def delete_cache
  validate_params
  raise "Rails not found... can't delete key" unless defined?(Rails)
  Rails.cache.delete(params["key"])
  ok
end

#delete_cache_listObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rack/bug/panels/cache_panel/panel_app.rb', line 32

def delete_cache_list
  validate_params
  raise "Rails not found... can't delete key" unless defined?(Rails)

  params.each do |key, value|
    next unless key =~ /^keys_/
    Rails.cache.delete(value)
  end

  ok
end

#dispatchObject



7
8
9
10
11
12
13
14
# File 'lib/rack/bug/panels/cache_panel/panel_app.rb', line 7

def dispatch
  case request.path_info
  when "/__rack_bug__/view_cache"         then view_cache
  when "/__rack_bug__/delete_cache"       then delete_cache
  when "/__rack_bug__/delete_cache_list"  then delete_cache_list
  else not_found
  end
end

#okObject



16
17
18
# File 'lib/rack/bug/panels/cache_panel/panel_app.rb', line 16

def ok
  Rack::Response.new(["OK"]).to_a
end

#view_cacheObject



20
21
22
23
# File 'lib/rack/bug/panels/cache_panel/panel_app.rb', line 20

def view_cache
  validate_params
  render_template "panels/view_cache", :key => params["key"], :value => Rails.cache.read(params["key"])
end