module ActiveSupport::Messages::Rotator

def initialize(*secrets, on_rotation: nil, **options)

:nodoc:
def initialize(*secrets, on_rotation: nil, **options)
  super(*secrets, **options)
  @options   = options
  @rotations = []
  @on_rotation = on_rotation
end

def rotate(*secrets, **options)

def rotate(*secrets, **options)
  @rotations << build_rotation(*secrets, @options.merge(options))
end

def run_rotations(on_rotation)

def run_rotations(on_rotation)
  @rotations.find do |rotation|
    if message = yield(rotation) rescue next
      on_rotation&.call
      return message
    end
  end
end