[Feature Proposal] Hash integration with ActiveSupport::ParameterFilter

I recently had a scenario where I wanted to log a hash of data for future debugging purposes but make sure sensitive credentials were not logged. This sounds a lot like the filtering done for ActionController and ActiveJob args/params.

I solved with a refinement which looks like this:

module FilterExtension
  refine Hash do
    def filtered
      config = Rails.application.config.filter_parameters
      scrubber = ActiveSupport::ParameterFilter.new config
      scrubber.filter self
    end
  end
end

Usage looks like:

using FilterExtension
....
Rails.logger.info "Publishing to #{topic}: #{payload.filtered}"

While this worked fairly well it felt like a lot of boilerplate. Seems we might want to encourage folks to filter their logs by making it easy. Might this make a good candidate to add to ActiveSupport so it can be done without the refinements?

If the response is positive I can work up a quick PR but wanted to check what people thought before I did any work.

Thanks!

Eric