Sha256: 105e6548095ff61e42ac04d33a058bf5a856af5aaa94c98e2f0111130061beae

Contents?: true

Size: 867 Bytes

Versions: 5

Compression:

Stored size: 867 Bytes

Contents

module Suj
  module Pusher

    def self.config
      @config ||= Suj::Pusher::Configuration.new
    end

    def self.configure
      yield config if block_given?
    end

    CONFIG_ATTRS = [
      :certs_path,
      :workdir,
      :logger,
      :redis_host,
      :redis_port,
      :redis_db,
      :redis_namespace
    ]

    class Configuration < Struct.new(*CONFIG_ATTRS)

      def initialize
        super
        set_defaults
      end

      def update(other)
        CONFIG_ATTRS.each do |attr|
          other_value = other.send(attr)
          send("#{attr}=", other_value) unless other_value.nil?
        end
      end

      def set_defaults
        self.redis_host = "localhost"
        self.redis_port = 6379
        self.redis_db = 0
        self.redis_namespace = "pusher"
        self.logger = ::Logger.new(STDOUT)
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
suj-pusher-0.2.5 lib/suj/pusher/configuration.rb
suj-pusher-0.2.3 lib/suj/pusher/configuration.rb
suj-pusher-0.2.0 lib/suj/pusher/configuration.rb
suj-pusher-0.1.5 lib/suj/pusher/configuration.rb
suj-pusher-0.1.4 lib/suj/pusher/configuration.rb