Sha256: a9ed36ee81f83c4d274b6d869271e8402fb32c1faf369fde2309a4799c795206

Contents?: true

Size: 1.32 KB

Versions: 15

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module PriceHubble
  # The top-level configuration handling.
  #
  # rubocop:disable Style/ClassVars because we split module code
  module ConfigurationHandling
    extend ActiveSupport::Concern

    class_methods do
      # Retrieve the current configuration object.
      #
      # @return [Configuration] the current configuration object
      def configuration
        @@configuration ||= Configuration.new
      end

      # Configure the concern by providing a block which takes
      # care of this task. Example:
      #
      #   FactoryBot::Instrumentation.configure do |conf|
      #     # conf.xyz = [..]
      #   end
      def configure
        yield(configuration)
      end

      # Reset the current configuration with the default one.
      def reset_configuration!
        @@configuration = Configuration.new
      end

      # Get back the credentials bundle for an authentication.
      #
      # @return [Hash{Symbol => String}] the identity bundle
      def identity_params
        {
          username: configuration.username,
          password: configuration.password
        }
      end

      # Retrieve the current configured logger instance.
      #
      # @return [Logger] the logger instance
      delegate :logger, to: :configuration
    end
  end
  # rubocop:enable Style/ClassVars
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pricehubble-1.3.0 lib/price_hubble/configuration_handling.rb
pricehubble-1.2.5 lib/price_hubble/configuration_handling.rb
pricehubble-1.2.4 lib/price_hubble/configuration_handling.rb
pricehubble-1.2.3 lib/price_hubble/configuration_handling.rb
pricehubble-1.2.2 lib/price_hubble/configuration_handling.rb
pricehubble-1.2.1 lib/price_hubble/configuration_handling.rb
pricehubble-1.2.0 lib/price_hubble/configuration_handling.rb
pricehubble-1.1.0 lib/pricehubble/configuration_handling.rb
pricehubble-1.0.0 lib/pricehubble/configuration_handling.rb
pricehubble-0.4.2 lib/pricehubble/configuration_handling.rb
pricehubble-0.4.1 lib/pricehubble/configuration_handling.rb
pricehubble-0.4.0 lib/pricehubble/configuration_handling.rb
pricehubble-0.3.0 lib/pricehubble/configuration_handling.rb
pricehubble-0.2.0 lib/pricehubble/configuration_handling.rb
pricehubble-0.1.0 lib/pricehubble/configuration_handling.rb