From 7f4d8e3fbd704cf1005a46309e3795192b114013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 15 Jan 2010 11:01:37 +0100 Subject: Yield the payload notifications for further modification (like adding the result). --- activesupport/lib/active_support/notifications.rb | 2 +- activesupport/lib/active_support/notifications/instrumenter.rb | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb index a1383bb478..3e96decb8c 100644 --- a/activesupport/lib/active_support/notifications.rb +++ b/activesupport/lib/active_support/notifications.rb @@ -45,7 +45,7 @@ module ActiveSupport class << self attr_writer :notifier delegate :publish, :subscribe, :to => :notifier - delegate :instrument, :instrument!, :to => :instrumenter + delegate :instrument, :to => :instrumenter def notifier @notifier ||= Notifier.new diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb index 85c5199946..f3d877efe7 100644 --- a/activesupport/lib/active_support/notifications/instrumenter.rb +++ b/activesupport/lib/active_support/notifications/instrumenter.rb @@ -13,19 +13,13 @@ module ActiveSupport # Instrument the given block by measuring the time taken to execute it # and publish it. - def instrument(name, payload={}, add_result=false) + def instrument(name, payload={}) time = Time.now - result = yield if block_given? - payload.merge!(:result => result) if add_result + result = yield(payload) if block_given? @notifier.publish(name, time, Time.now, @id, payload) result end - # The same as instrument, but adds the result as payload. - def instrument!(name, payload={}, &block) - instrument(name, payload, true, &block) - end - private def unique_id SecureRandom.hex(10) -- cgit v1.2.3