Sha256: bfefaf676963cee36de7eae316ac481bdac9ab3fcb95a10e2e9c3b5368659b4d

Contents?: true

Size: 1.01 KB

Versions: 24

Compression:

Stored size: 1.01 KB

Contents

module Pheme
  class << self
    attr_writer :configuration
  end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.configure
    yield(configuration)
  end

  def self.reset_configuration!
    @configuration = Configuration.new
  end

  class Configuration
    ATTRIBUTES = %i[sns_client sqs_client logger].freeze
    OPTIONAL_ATTRIBUTES = %i[rollbar].freeze

    attr_accessor(*ATTRIBUTES, *OPTIONAL_ATTRIBUTES)

    def initialize
      @logger ||= Logger.new(STDOUT) # rubocop:disable Lint/DisjunctiveAssignmentInConstructor
      @logger = ActiveSupport::TaggedLogging.new(@logger) unless @logger.respond_to?(:tagged)
    end

    def validate!
      ATTRIBUTES.each do |attribute|
        raise "Invalid or missing configuration for #{attribute}" if send(attribute).blank?
      end
      raise "sns_client must be a Aws::SNS::Client"  unless sns_client.is_a?(Aws::SNS::Client)
      raise "sns_client must be a Aws::SQS::Client"  unless sqs_client.is_a?(Aws::SQS::Client)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
pheme-5.0.8 lib/pheme/configuration.rb
pheme-5.0.7 lib/pheme/configuration.rb
pheme-5.0.6 lib/pheme/configuration.rb
pheme-5.0.5 lib/pheme/configuration.rb
pheme-5.0.4 lib/pheme/configuration.rb
pheme-5.0.3 lib/pheme/configuration.rb
pheme-5.0.2 lib/pheme/configuration.rb
pheme-5.0.1 lib/pheme/configuration.rb
pheme-5.0.0 lib/pheme/configuration.rb
pheme-4.1.1 lib/pheme/configuration.rb
pheme-4.1.0 lib/pheme/configuration.rb
pheme-4.0.15 lib/pheme/configuration.rb
pheme-4.0.14 lib/pheme/configuration.rb
pheme-4.0.13 lib/pheme/configuration.rb
pheme-4.0.12 lib/pheme/configuration.rb
pheme-4.0.11 lib/pheme/configuration.rb
pheme-4.0.10 lib/pheme/configuration.rb
pheme-4.0.9 lib/pheme/configuration.rb
pheme-4.0.8 lib/pheme/configuration.rb
pheme-4.0.7 lib/pheme/configuration.rb