Sha256: 611ff178c9963e56abf34d4f6eb93fca466c86cd016896909480db17b2860089

Contents?: true

Size: 606 Bytes

Versions: 1

Compression:

Stored size: 606 Bytes

Contents

require 'attempt_this/attempt_object'

module AttemptThis
  extend self

  # Attempts code block until it doesn't throw an exception or the end of enumerator has been reached.
  def attempt(enumerator, &block)
    raise(ArgumentError, 'Nil enumerator!') if enumerator.nil?

    impl = AttemptObject::get_object(enumerator)
    impl.attempt(block)
  end

  def enabled?
    @enabled.nil? || @enabled
  end

  def enabled=(value)
    @enabled = value
  end

  # Resets all static data (scenarios). This is intended to use by tests only (to reset scenarios)
  def self.reset
    AttemptObject.reset
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
attempt_this-1.0.2 lib/attempt_this/attempt_this.rb