diff options
author | Guilherme Mansur <guilherme.mansur@shopify.com> | 2019-05-21 17:07:27 -0400 |
---|---|---|
committer | Guilherme Mansur <guilherme.mansur@shopify.com> | 2019-05-22 14:11:03 -0400 |
commit | 218f0777d6abf1b2f933e44bd08f75f3d28c75ca (patch) | |
tree | 273f446a349d25bd7a9d899d5a90d5488e3e7a8d /guides/source | |
parent | 3453c5d4c0b54fc2a117a09ff4d5964110f5fbe8 (diff) | |
download | rails-218f0777d6abf1b2f933e44bd08f75f3d28c75ca.tar.gz rails-218f0777d6abf1b2f933e44bd08f75f3d28c75ca.tar.bz2 rails-218f0777d6abf1b2f933e44bd08f75f3d28c75ca.zip |
Merge payload for EventObject subscribers
When instrumenting a block of code like:
```ruby
ActiveSupport::Notifications.instrument("process_action.action_controller", raw_paylaod) do |payload|
payload[:view_runtime] = render_view
end
```
If we use an evented subscriber like so:
``` ruby
ActiveSupport::Notifications.subscribe("process_action.action_controller", raw_payload) do |event|
assert event.payload[:view_runtime]
end
```
The code breaks because the underlying EventObject's payload does not have the
`:view_runtime` key added during instrumentation.
This is because the `EventedObject` subscriber calls the `finish` method with the
`payload` of the event at the time it was pushed into the stack, before the
block executes, but we want to call `finish` with the `payload` after the
instrument block executes this way if the `payload` was modified during the block
we have access to it. This is consistent with the other types of subscribers
who don't have this bug.
Diffstat (limited to 'guides/source')
0 files changed, 0 insertions, 0 deletions