Sha256: d2a5005438d20e987ae6ad763a84b45e1e8809fb8358c3c835d7c7c6563c41d2

Contents?: true

Size: 711 Bytes

Versions: 28

Compression:

Stored size: 711 Bytes

Contents

class Eye::Patch::Config < Hash

  def initialize(settings)
    super()
    self.merge!(parse(settings))
  end

  private

  def parse(settings)
    return @config if @config
    @config = {}

    parse_config(settings)
    parse_contacts(settings)

    @config
  end

  def parse_config(settings)
    @config.merge!(settings[:config] || {})
  end

  def parse_contacts(settings)
    @config[:contacts] = {}
    Array(settings[:notifications]).each do |notify|
      @config[notify[:type].to_sym] = notify[:config]
      @config[:contacts][notify[:name].to_s] = {
        name: notify[:name].to_s,
        type: notify[:type].to_sym,
        contact: notify[:contact].to_s,
        opts: {} }
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
eye-patch-0.5.1 lib/eye/patch/config.rb
eye-patch-0.5.0 lib/eye/patch/config.rb
eye-patch-0.4.2 lib/eye/patch/config.rb
eye-patch-0.4.1 lib/eye/patch/config.rb
eye-patch-0.4.0 lib/eye/patch/config.rb
eye-patch-0.3.1 lib/eye/patch/config.rb
eye-patch-0.3.0 lib/eye/patch/config.rb
eye-patch-0.2.2 lib/eye/patch/config.rb
eye-patch-0.2.1 lib/eye/patch/config.rb
eye-patch-0.2.0 lib/eye/patch/config.rb
eye-patch-0.1.8 lib/eye/patch/config.rb
eye-patch-0.1.7 lib/eye/patch/config.rb
eye-patch-0.1.6 lib/eye/patch/config.rb
eye-patch-0.1.5 lib/eye/patch/config.rb
eye-patch-0.1.4 lib/eye/patch/config.rb
eye-patch-0.1.3 lib/eye/patch/config.rb
eye-patch-0.1.2 lib/eye/patch/config.rb
eye-patch-0.1.1 lib/eye/patch/config.rb
eye-patch-0.1.0 lib/eye/patch/config.rb
eye-patch-0.0.9 lib/eye/patch/config.rb