From a6dc227167a8a720bd18495268305b15aa08d8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 17 Mar 2010 23:44:03 +0100 Subject: Mark bang instrumentations as something that you shuold not be listening to. --- actionpack/lib/action_controller/test_case.rb | 4 ++-- actionpack/lib/action_view/template.rb | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 107f70d3a3..330b950d7c 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -13,7 +13,7 @@ module ActionController def setup_subscriptions @partials = Hash.new(0) @templates = Hash.new(0) - ActiveSupport::Notifications.subscribe("action_view.slow_render_template") do |name, start, finish, id, payload| + ActiveSupport::Notifications.subscribe("action_view.render_template!") do |name, start, finish, id, payload| path = payload[:virtual_path] next unless path partial = path =~ /^.*\/_[^\/]*$/ @@ -28,7 +28,7 @@ module ActionController end def teardown_subscriptions - ActiveSupport::Notifications.unsubscribe("action_view.slow_render_template") + ActiveSupport::Notifications.unsubscribe("action_view.render_template!") end # Asserts that the request was rendered with the appropriate template file or partials diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index ad37eb4c4a..9145d007a8 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -23,7 +23,6 @@ module ActionView @identifier = identifier @handler = handler - @partial = details[:partial] @virtual_path = details[:virtual_path] @method_names = {} @@ -36,9 +35,9 @@ module ActionView end def render(view, locals, &block) - # TODO: Revisit this name - # This is only slow if it's being listened to. Do not instrument this in production. - ActiveSupport::Notifications.instrument("action_view.slow_render_template", :virtual_path => @virtual_path) do + # Notice that 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. + ActiveSupport::Notifications.instrument("action_view.render_template!", :virtual_path => @virtual_path) do method_name = compile(locals, view) view.send(method_name, locals, &block) end @@ -63,10 +62,6 @@ module ActionView @counter_name ||= "#{variable_name}_counter".to_sym end - def partial? - @partial - end - def inspect if defined?(Rails.root) identifier.sub("#{Rails.root}/", '') -- cgit v1.2.3