kick different instrumentation method

We can eliminate a conditional by calling a different instrumentation
method depending on the situation.  In this case, we'll call the special
case "!render_template" instrumentation method and eliminate the case /
when clause from the `instrument` method.
上级 c1049403
......@@ -152,7 +152,7 @@ def supports_streaming?
# we use a bang in this instrumentation because you don't want to
# consume this in production. This is only slow if it's being listened to.
def render(view, locals, buffer=nil, &block)
instrument("!render_template".freeze) do
instrument_render_template do
compile!(view)
view.send(method_name, locals, buffer, &block)
end
......@@ -341,13 +341,17 @@ def identifier_method_name #:nodoc:
end
def instrument(action, &block)
payload = { virtual_path: @virtual_path, identifier: @identifier }
case action
when "!render_template"
ActiveSupport::Notifications.instrument("!render_template.action_view".freeze, payload, &block)
else
ActiveSupport::Notifications.instrument("#{action}.action_view".freeze, payload, &block)
end
ActiveSupport::Notifications.instrument("#{action}.action_view".freeze, instrument_payload, &block)
end
private
def instrument_render_template(&block)
ActiveSupport::Notifications.instrument("!render_template.action_view".freeze, instrument_payload, &block)
end
def instrument_payload
{ virtual_path: @virtual_path, identifier: @identifier }
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册