diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2016-08-24 16:01:55 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2016-08-24 16:01:55 -0700 |
commit | 804f5b3c2af90b69a51209c56739a077f3fb632b (patch) | |
tree | 775ba004ce2f11288490e6843b0d0d6859129728 /actionview/lib/action_view | |
parent | c104940363ee616c3ea9e0eeb085e39740211fdf (diff) | |
download | rails-804f5b3c2af90b69a51209c56739a077f3fb632b.tar.gz rails-804f5b3c2af90b69a51209c56739a077f3fb632b.tar.bz2 rails-804f5b3c2af90b69a51209c56739a077f3fb632b.zip |
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.
Diffstat (limited to 'actionview/lib/action_view')
-rw-r--r-- | actionview/lib/action_view/template.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index d75457f1eb..513935cef0 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -152,7 +152,7 @@ module ActionView # 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 @@ module ActionView 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 |