diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2019-02-04 17:41:40 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2019-02-04 17:41:40 -0500 |
commit | 3cf57007bfcba8172a0f5cce445bb364720d5665 (patch) | |
tree | 839a4958bc9aef7b868ce2dd3fc540749e3dac19 /activesupport/lib/active_support | |
parent | 3cace9eac95fb4ec8d4b7045b60c5cc9b7b02d01 (diff) | |
parent | 2ce8455cc994c788a44f5b414769cb2dbee4577d (diff) | |
download | rails-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')
-rw-r--r-- | activesupport/lib/active_support/current_attributes.rb | 6 |
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 |