Module: ConvenientService::Support::FiniteLoop Private
- Included in:
- Utils::Module::GetOwnInstanceMethod
- Defined in:
- lib/convenient_service/support/finite_loop.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Modules: Exceptions
Constant Summary collapse
- MAX_ITERATION_COUNT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
1_000
Class Method Summary collapse
-
.finite_loop(default: nil, max_iteration_count: MAX_ITERATION_COUNT, raise_on_exceedance: true, &block) ⇒ Object
private
Can be any type.
Class Method Details
.finite_loop(default: nil, max_iteration_count: MAX_ITERATION_COUNT, raise_on_exceedance: true, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns Can be any type.
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/convenient_service/support/finite_loop.rb', line 74 def finite_loop(default: nil, max_iteration_count: MAX_ITERATION_COUNT, raise_on_exceedance: true, &block) ::ConvenientService.raise Exceptions::NoBlockGiven.new unless block loop.with_index do |_, index| if index >= max_iteration_count break default unless raise_on_exceedance ::ConvenientService.raise Exceptions::MaxIterationCountExceeded.new(limit: max_iteration_count) end yield(index) end end |