rails
rails copied to clipboard
Support using a method name to define the `ActiveSupport::CurrentAttributes.resets` callback
Previously you could only use a block, which was inconsistent with other callback APIs in Rails. Now, you can use a block or a method name. The block API is still recommended in the docs. So now these do the same thing:
class CurrentWithBlock < ActiveSupport::CurrentAttributes
resets { Time.zone = nil }
end
class CurrentWithMethod < ActiveSupport::CurrentAttributes
resets :reset_time_zone
def reset_time_zone
Time.zone = nil
end
end
This also works for before_reset
.
class Current < ActiveSupport::CurrentAttributes
before_reset :reset_time_zone
end