17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/rails-idle/collector/views.rb', line 17
def subscribe
%w{render_template render_partial render_collection}.each do |event|
ActiveSupport::Notifications.subscribe("#{event}.action_view") do |name, started, finished, unique_id, payload|
orig_prefix = ''
view = modify_prefix payload[:identifier], orig_prefix
next unless view
execution_time = finished.to_f - started.to_f
push(view, execution_time)
if payload[:layout] && view =~ /\.\w+\.\w+$/
extension = view.match(/\.\w+\.\w+$/)[0]
layout = orig_prefix + '/' + payload[:layout] + extension
layout = modify_prefix layout
push(layout, execution_time) if layout
end
end
end
end
|