From 3699ec9d1bd48332d1aef7def38f913c4773257c Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 26 Jul 2018 14:54:47 -0700 Subject: Add changelog entry --- activesupport/CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'activesupport/CHANGELOG.md') diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 10a25a120d..e789d7fa20 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,37 @@ +* Add "event object" support to the notification system. + Before this change, end users were forced to create hand made arsenal + event objects on their own, like this: + + ActiveSupport::Notifications.subscribe('wait') do |*args| + @event = ActiveSupport::Notifications::Event.new(*args) + end + + ActiveSupport::Notifications.instrument('wait') do + sleep 1 + end + + @event.duration # => 1000.138 + + After this change, if the block passed to `subscribe` only takes one + parameter, the framework will yield an event object to the block. Now + end users are no longer required to make their own: + + ActiveSupport::Notifications.subscribe('wait') do |event| + @event = event + end + + ActiveSupport::Notifications.instrument('wait') do + sleep 1 + end + + p @event.allocations # => 7 + p @event.cpu_time # => 0.256 + p @event.idle_time # => 1003.2399 + + Now you can enjoy event objects without making them yourself. Neat! + + *Aaron "t.lo" Patterson* + * Add cpu_time, idle_time, and allocations to Event *Eileen M. Uchitelle*, *Aaron Patterson* -- cgit v1.2.3