Sha256: 57b1c37fbde8f0f4c3796a1b86be9e5515339e0a277226dc2b53e754daa013ec

Contents?: true

Size: 696 Bytes

Versions: 2

Compression:

Stored size: 696 Bytes

Contents

module QPush
  module Base
    module ConfigHelper
      def self.included(base)
        base.extend(ClassMethods)
      end

      module ClassMethods
        def configure
          reset
          yield(config)
        end

        def reset
          @config = nil
          @redis_pool = nil
        end
      end
    end

    class Config
      DEFAULTS = {
        redis_url: ENV['REDIS_URL'],
        redis_pool: 10
      }.freeze

      attr_accessor :redis_url, :redis_pool

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qpush-0.1.10 lib/qpush/base/config.rb
qpush-0.1.8 lib/qpush/base/config.rb