Class: Rack::WebProfiler::Controller
- Inherits:
-
Object
- Object
- Rack::WebProfiler::Controller
- Defined in:
- lib/rack/web_profiler/controller.rb
Overview
Controller
Generate the views of the WebProfiler.
Instance Method Summary collapse
-
#delete ⇒ Rack::Response
Clean the webprofiler.
-
#index ⇒ Rack::Response
List the webprofiler history.
-
#initialize(request) ⇒ Controller
constructor
Initialize.
-
#show(token) ⇒ Rack::Response
Show the webprofiler panel.
-
#show_toolbar(token) ⇒ Rack::Response
Print the webprofiler toolbar.
Constructor Details
#initialize(request) ⇒ Controller
Initialize.
13 14 15 |
# File 'lib/rack/web_profiler/controller.rb', line 13 def initialize(request) @request = request end |
Instance Method Details
#delete ⇒ Rack::Response
Clean the webprofiler.
72 73 74 75 76 |
# File 'lib/rack/web_profiler/controller.rb', line 72 def delete Rack::WebProfiler::Model.clean! redirect WebProfiler::Router.url_for_profiler end |
#index ⇒ Rack::Response
List the webprofiler history.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rack/web_profiler/controller.rb', line 20 def index @collections = Rack::WebProfiler::Model::CollectionRecord.order(Sequel.desc(:created_at)) .limit(20) return json(@collections, to_json_opts: { only: [:token, :http_method, :http_status, :url, :ip] }) if prefer_json? erb "panel/index.erb", layout: "panel/layout.erb" end |
#show(token) ⇒ Rack::Response
Show the webprofiler panel.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rack/web_profiler/controller.rb', line 36 def show(token) @collection = Rack::WebProfiler::Model::CollectionRecord[token: token] return not_found if @collection.nil? @collectors = Rack::WebProfiler.config.collectors.all @collector = nil unless @request.params["panel"].nil? @collector = @collectors[@request.params["panel"].to_sym] else @collector = @collectors.values.first end return not_found if @collector.nil? return json(@collection) if prefer_json? erb "panel/show.erb", layout: "panel/layout.erb" end |
#show_toolbar(token) ⇒ Rack::Response
Print the webprofiler toolbar.
60 61 62 63 64 65 66 67 |
# File 'lib/rack/web_profiler/controller.rb', line 60 def (token) @collection = Rack::WebProfiler::Model::CollectionRecord[token: token] return erb nil, status: 404 if @collection.nil? @collectors = Rack::WebProfiler.config.collectors.all erb "profiler.erb" end |