Module: ActiveSupport::Messages::Rotator
Do not use. This module is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | activesupport/lib/active_support/messages/rotator.rb |
Instance Method Summary
Instance Method Details
#build_rotation(*args, **options) (private)
[ GitHub ]# File 'activesupport/lib/active_support/messages/rotator.rb', line 44
def build_rotation(*args, ** ) self.class.new(*args, *@args.drop(args.length), **@options, ** ) end
#catch_rotation_error(&block) (private)
[ GitHub ]# File 'activesupport/lib/active_support/messages/rotator.rb', line 48
def catch_rotation_error(&block) error = catch : do error = catch : do return [nil, block.call] end return [:, error] end [:, error] end
#fall_back_to(fallback)
[ GitHub ]# File 'activesupport/lib/active_support/messages/rotator.rb', line 18
def fall_back_to(fallback) @rotations << fallback self end
#initialize(*args, on_rotation: nil, **options)
[ GitHub ]# File 'activesupport/lib/active_support/messages/rotator.rb', line 6
def initialize(*args, on_rotation: nil, ** ) super(*args, ** ) @args = args @options = @rotations = [] @on_rotation = on_rotation end
#read_message(message, on_rotation: @on_rotation, **options)
[ GitHub ]# File 'activesupport/lib/active_support/messages/rotator.rb', line 23
def (, on_rotation: @on_rotation, ** ) if @rotations.empty? super(, ** ) else thrown, error = catch_rotation_error do return super(, ** ) end @rotations.each do |rotation| catch_rotation_error do value = rotation. (, ** ) on_rotation&.call return value end end throw thrown, error end end
#rotate(*args, **options)
[ GitHub ]# File 'activesupport/lib/active_support/messages/rotator.rb', line 14
def rotate(*args, ** ) fall_back_to build_rotation(*args, ** ) end