aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/current_attributes.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2019-02-04 17:41:40 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2019-02-04 17:41:40 -0500
commit3cf57007bfcba8172a0f5cce445bb364720d5665 (patch)
tree839a4958bc9aef7b868ce2dd3fc540749e3dac19 /activesupport/lib/active_support/current_attributes.rb
parent3cace9eac95fb4ec8d4b7045b60c5cc9b7b02d01 (diff)
parent2ce8455cc994c788a44f5b414769cb2dbee4577d (diff)
downloadrails-3cf57007bfcba8172a0f5cce445bb364720d5665.tar.gz
rails-3cf57007bfcba8172a0f5cce445bb364720d5665.tar.bz2
rails-3cf57007bfcba8172a0f5cce445bb364720d5665.zip
Merge pull request #35063 from rosa/current-before-reset-callback
Support before_reset callback in CurrentAttributes
Diffstat (limited to 'activesupport/lib/active_support/current_attributes.rb')
-rw-r--r--activesupport/lib/active_support/current_attributes.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/current_attributes.rb b/activesupport/lib/active_support/current_attributes.rb
index 3145ff87a1..67ebe102d7 100644
--- a/activesupport/lib/active_support/current_attributes.rb
+++ b/activesupport/lib/active_support/current_attributes.rb
@@ -119,10 +119,16 @@ module ActiveSupport
end
end
+ # Calls this block before #reset is called on the instance. Used for resetting external collaborators that depend on current values.
+ def before_reset(&block)
+ set_callback :reset, :before, &block
+ end
+
# Calls this block after #reset is called on the instance. Used for resetting external collaborators, like Time.zone.
def resets(&block)
set_callback :reset, :after, &block
end
+ alias_method :after_reset, :resets
delegate :set, :reset, to: :instance