Class: Rack::Insight::CachePanel::PanelApp

Inherits:
PanelApp
  • Object
show all
Defined in:
lib/rack/insight/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

Methods included from Logging

logger, verbose, verbosity

Instance Method Details

#delete_cacheObject



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

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



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

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



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

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

#okObject



15
16
17
# File 'lib/rack/insight/panels/cache_panel/panel_app.rb', line 15

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

#view_cacheObject



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

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