Sha256: af695b8a7720a7f5dcd88ae9e89cb6bb44cc9e4bb8c53e59d0272deddcc3437d

Contents?: true

Size: 755 Bytes

Versions: 1

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

module Fuli
  class Config
    attr_accessor :logger, :warn_notifiers, :error_notifiers

    def initialize(config_hash = {})
      self.logger = config_hash[:logger]
      self.warn_notifiers = config_hash[:warn_notifiers] || []
      self.error_notifiers = config_hash[:error_notifiers] || []
      merge(config_hash)
    end

    class << self
      attr_writer :instance

      def instance
        @instance ||= new
      end
    end

    private

    def merge(config_hash)
      config_hash.each_pair(&method(:set_option))
      self
    end

    def set_option(option, value)
      __send__("#{option}=", value)
    rescue NoMethodError
      raise Fuli::Error, "unknown config option '#{option}'"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fuli_the_guard-0.1.1 lib/fuli/config.rb