Class: Grumlin::Repository::ErrorHandlingStrategy
- Inherits:
-
Object
- Object
- Grumlin::Repository::ErrorHandlingStrategy
- Defined in:
- lib/grumlin/repository/error_handling_strategy.rb
Instance Method Summary collapse
- #apply! ⇒ Object
- #ignore? ⇒ Boolean
-
#initialize(mode: :retry, **params) ⇒ ErrorHandlingStrategy
constructor
A new instance of ErrorHandlingStrategy.
- #raise? ⇒ Boolean
- #retry? ⇒ Boolean
Constructor Details
#initialize(mode: :retry, **params) ⇒ ErrorHandlingStrategy
Returns a new instance of ErrorHandlingStrategy.
4 5 6 7 8 |
# File 'lib/grumlin/repository/error_handling_strategy.rb', line 4 def initialize(mode: :retry, **params) @mode = mode @params = params @on_exceptions = params[:on] end |
Instance Method Details
#apply! ⇒ Object
22 23 24 25 26 27 |
# File 'lib/grumlin/repository/error_handling_strategy.rb', line 22 def apply!(&) return yield if raise? return ignore_errors!(&) if ignore? retry_errors!(&) end |
#ignore? ⇒ Boolean
14 15 16 |
# File 'lib/grumlin/repository/error_handling_strategy.rb', line 14 def ignore? @mode == :ignore end |
#raise? ⇒ Boolean
10 11 12 |
# File 'lib/grumlin/repository/error_handling_strategy.rb', line 10 def raise? @mode == :raise end |
#retry? ⇒ Boolean
18 19 20 |
# File 'lib/grumlin/repository/error_handling_strategy.rb', line 18 def retry? @mode == :retry end |