Sha256: 119258add52d6e77d1db9220cea4e31c6c4a32dc1fe6a6d923e09752e7bcbb5e

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

module WaterDrop
  # Configurator for setting up all options required by WaterDrop
  class Config
    class << self
      attr_accessor :config
    end

    # Available options
    # @option connection_pool_size [Fixnum] The number of connections to pool.
    # @option connection_pool_timeout [Fixnum] Amount of time in seconds to wait for a connection
    #         if none currently available.
    # @option kafka_hosts [Array<String>] Array that contains Kafka hosts with ports
    # @option send_messages [Boolean] boolean value to define whether messages should be sent
    # @option raise_on_failure [Boolean] Should raise error when failed to deliver a message
    OPTIONS = %i(
      connection_pool_size
      connection_pool_timeout
      kafka_hosts
      send_messages
      raise_on_failure
    )

    OPTIONS.each do |attr_name|
      attr_accessor attr_name

      # @return [Boolean] is given command enabled
      define_method :"#{attr_name}?" do
        public_send(attr_name) == true
      end
    end

    # Configurating method
    def self.setup(&block)
      self.config = new

      block.call(config)
      config.freeze
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
waterdrop-0.2.1 lib/water_drop/config.rb
waterdrop-0.2.0 lib/water_drop/config.rb
waterdrop-0.1.13 lib/water_drop/config.rb
waterdrop-0.1.12 lib/water_drop/config.rb
waterdrop-0.1.11 lib/water_drop/config.rb
waterdrop-0.1.10 lib/water_drop/config.rb
waterdrop-0.1.9 lib/water_drop/config.rb
waterdrop-0.1.8 lib/water_drop/config.rb
waterdrop-0.1.7 lib/water_drop/config.rb