Sha256: c9ea2ebcb809f62c2f2c169eabe261eba8ac9efe5f32c75eaff4f4e874778db0

Contents?: true

Size: 528 Bytes

Versions: 13

Compression:

Stored size: 528 Bytes

Contents

module Kredis::Types::Proxy::Failsafe
  def initialize(*)
    super
    @fail_safe_suppressed = false
  end

  def failsafe
    yield
  rescue Redis::BaseError
    raise if fail_safe_suppressed?
  end

  def suppress_failsafe_with(returning: nil)
    old_fail_safe_suppressed, @fail_safe_suppressed = @fail_safe_suppressed, true
    yield
  rescue Redis::BaseError
    returning
  ensure
    @fail_safe_suppressed = old_fail_safe_suppressed
  end

  private
    def fail_safe_suppressed?
      @fail_safe_suppressed
    end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
kredis-1.5.0 lib/kredis/types/proxy/failsafe.rb
kredis-1.4.0 lib/kredis/types/proxy/failsafe.rb
kredis-1.3.0.1 lib/kredis/types/proxy/failsafe.rb
kredis-1.3.0 lib/kredis/types/proxy/failsafe.rb
kredis-1.2.0 lib/kredis/types/proxy/failsafe.rb
kredis-1.1.0 lib/kredis/types/proxy/failsafe.rb
kredis-1.0.1 lib/kredis/types/proxy/failsafe.rb
kredis-1.0.0 lib/kredis/types/proxy/failsafe.rb
kredis-0.4.0 lib/kredis/types/proxy/failsafe.rb
kredis-0.3.1 lib/kredis/types/proxy/failsafe.rb
kredis-0.3.0 lib/kredis/types/proxy/failsafe.rb
kredis-0.2.3 lib/kredis/types/proxy/failsafe.rb
kredis-0.2.2 lib/kredis/types/proxy/failsafe.rb