From 45462c5e41a77e600878f7b8b2e41babeef8fe8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 4 Jan 2010 22:22:21 +0100 Subject: Expose Instrumenter id in Notifications. --- activesupport/lib/active_support/notifications/instrumenter.rb | 2 ++ activesupport/test/notifications_test.rb | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb index 0655dd0cb6..3b0b0d8da2 100644 --- a/activesupport/lib/active_support/notifications/instrumenter.rb +++ b/activesupport/lib/active_support/notifications/instrumenter.rb @@ -4,6 +4,8 @@ require 'active_support/core_ext/module/delegation' module ActiveSupport module Notifications class Instrumenter + attr_reader :id + def initialize(notifier) @id = unique_id @notifier = notifier diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb index 3ba77ae135..ef6e6d8d22 100644 --- a/activesupport/test/notifications_test.rb +++ b/activesupport/test/notifications_test.rb @@ -86,6 +86,10 @@ module Notifications assert_equal 2, @notifier.instrument(:awesome) { 1 + 1 } end + def test_instrumenter_exposes_its_id + assert_equal 20, ActiveSupport::Notifications::Instrumenter.new(@notifier).id.size + end + def test_nested_events_can_be_instrumented @notifier.instrument(:awesome, :payload => "notifications") do @notifier.instrument(:wot, :payload => "child") do -- cgit v1.2.3