Sha256: 3771228e23f47329578bc42da1435e237280ca52f6bb4572c63dcc6d2568ce96

Contents?: true

Size: 713 Bytes

Versions: 3

Compression:

Stored size: 713 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
    ]

    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 = "redis://localhost:6379"
        self.logger = ::Logger.new(STDOUT)
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
suj-pusher-0.1.3 lib/suj/pusher/configuration.rb
suj-pusher-0.1.0 lib/suj/pusher/configuration.rb
suj-pusher-0.0.1 lib/suj/pusher/configuration.rb