Module: ActiveSupport::Messages::Rotator
- Defined in:
- activesupport/lib/active_support/messages/rotator.rb
Overview
:nodoc:
Instance Method Summary collapse
- #fall_back_to(fallback) ⇒ Object
- #initialize(*args, on_rotation: nil, **options) ⇒ Object
- #read_message(message, on_rotation: @on_rotation, **options) ⇒ Object
- #rotate(*args, **options) ⇒ Object
Instance Method Details
#fall_back_to(fallback) ⇒ Object
18 19 20 21 |
# 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) ⇒ Object
6 7 8 9 10 11 12 |
# 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) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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) ⇒ Object
14 15 16 |
# File 'activesupport/lib/active_support/messages/rotator.rb', line 14 def rotate(*args, **) fall_back_to build_rotation(*args, **) end |