{Rack::WebProfiler::Collector::DSL} {Rack::WebProfiler::Collector::DSL::ClassMethods}
Technical identifier of the collector.
example
identifier "my_collector"
The label is shown in panel sidebar.
example
label "My Collector"
Base64 encoded image for the icon collector.
example
icon <<-'ICON'
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8Xw8AAoMBgDTD2qgAAAAASUVORK5CYII=
ICON
Position of the collector in the toolbar.
example
position 2
Place to collect data to store. It give you access to the {Rack::WebProfiler::Request} and the {Rack::WebProfiler::Response}.
Inside you could store
the datas you want. And you also could set a status
.
There is success
, warning
and error
has available status
.
example
collect do |request, response|
store :url, request.url
store :key, ["v1", "v2"]
status :success if response.successful?
end
example
template "../path/to/template.erb"
# Or
template __FILE__, type: :DATA
example
is_enabled? -> { defined? MyApp }
It's really simple to register a Collector or an {Array} of collectors.
Rack::WebProfiler.register_collector MyCustomCollector
Rack::WebProfiler.register_collector [MyCustomCollector, MySecondCustomCollector]
You could also unregister a collector
Rack::WebProfiler.unregister_collector MyCustomCollector
Rack::WebProfiler.unregister_collector [MyCustomCollector, MySecondCustomCollector]
class MyCustomCollector
include Rack::WebProfiler::Collector::DSL
icon <<-'ICON'
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8Xw8AAoMBgDTD2qgAAAAASUVORK5CYII=
ICON
identifier "my_collector"
label "My Collector"
position 2
collect do |request, response|
store :url, request.url
store :key, ["v1", "v2"]
status :success if response.successful?
end
template __FILE__, type: :DATA
is_enabled? -> { defined? MyApp }
end
__END__
<% tab_content do %>
<%=h data(:url) %>
<% end %>
<%# panel_content do %>
<ul>
<li><%=h data(:url) %></li>
<li><%=h data(:key).inspect %></li>
</ul>
<%# end %>