Sha256: f0a43a8d0e4d8cbe19aac4bc57ab47b45514149d8714f16b543bf044c28e8e07

Contents?: true

Size: 879 Bytes

Versions: 5

Compression:

Stored size: 879 Bytes

Contents

module ActiveHook
  class << self
    def configure
      reset
      yield(config)
    end

    def config
      @config ||= build_config
    end

    def build_config
      klass =
        case ActiveHook.mode
        when :server then ActiveHook::Server::Config
        when :client then ActiveHook::Client::Config
        else ActiveHook::App::Config
        end
      klass.new
    end

    def reset
      @config = nil
      @connection_pool = nil
    end
  end

  class BaseConfig
    BASE_DEFAULTS = {
      redis_url: ENV['REDIS_URL'],
      redis_pool: 5,
      signature_header: 'X-Webhook-Signature'
    }.freeze

    attr_accessor :redis_url, :redis_pool, :signature_header

    def initialize
      BASE_DEFAULTS.each { |key, value| send("#{key}=", value) }
    end

    def redis
      {
        size: redis_pool,
        url: redis_url
      }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activehook-0.1.9 lib/activehook/config.rb
activehook-0.1.8 lib/activehook/config.rb
activehook-0.1.7 lib/activehook/config.rb
activehook-0.1.6 lib/activehook/config.rb
activehook-0.1.5 lib/activehook/config.rb