Class: Grumlin::Repository::ErrorHandlingStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/grumlin/repository/error_handling_strategy.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


14
15
16
# File 'lib/grumlin/repository/error_handling_strategy.rb', line 14

def ignore?
  @mode == :ignore
end

#raise?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/grumlin/repository/error_handling_strategy.rb', line 10

def raise?
  @mode == :raise
end

#retry?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/grumlin/repository/error_handling_strategy.rb', line 18

def retry?
  @mode == :retry
end