Sha256: b4c63a78d26ada43284cc565adbbc497dea424a120e5942400cd9a517bf8c62c

Contents?: true

Size: 814 Bytes

Versions: 3

Compression:

Stored size: 814 Bytes

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 = [:sns_client, :sqs_client, :logger]
    attr_accessor *ATTRIBUTES

    def initialize
      @logger ||= Logger.new(STDOUT)
    end

    def validate!
      ATTRIBUTES.each do |attribute|
        raise "Invalid or missing configuration for #{attribute}"  unless send(attribute).present?
      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

3 entries across 3 versions & 1 rubygems

Version Path
pheme-0.0.3 lib/pheme/configuration.rb
pheme-0.0.2 lib/pheme/configuration.rb
pheme-0.0.1 lib/pheme/configuration.rb