Sha256: ae8c32b8bacc837a522f490703c8228029234bcbd39de6fa6c0a41ff45362bcb

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

require 'aptible/resource/version'
require 'aptible/resource/base'
require 'aptible/resource/default_retry_coordinator'
require 'aptible/resource/null_retry_coordinator'
require 'gem_config'

module Aptible
  module Resource
    include GemConfig::Base

    RETRY_COORDINATOR_OVERRIDE = :override_retry_coordinator_class

    with_configuration do
      has :retry_coordinator_class,
          classes: [Class],
          default: DefaultRetryCoordinator

      has :user_agent,
          classes: [String],
          default: "aptible-resource #{Aptible::Resource::VERSION}"
    end

    class << self
      def without_retry(&block)
        override_retry_coordinator_class(
          Aptible::Resource::NullRetryCoordinator, &block
        )
      end

      def override_retry_coordinator_class(klass)
        Thread.current[RETRY_COORDINATOR_OVERRIDE] = klass
        yield if block_given?
      ensure
        Thread.current[RETRY_COORDINATOR_OVERRIDE] = nil
      end

      def retry_coordinator_class
        override = Thread.current[RETRY_COORDINATOR_OVERRIDE]
        return override if override
        configuration.retry_coordinator_class
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aptible-resource-1.0.2 lib/aptible/resource.rb
aptible-resource-1.0.1 lib/aptible/resource.rb
aptible-resource-1.0.0 lib/aptible/resource.rb
aptible-resource-0.5.0 lib/aptible/resource.rb
aptible-resource-0.4.0 lib/aptible/resource.rb