class SiteHook::LogLevels

Attributes

app[RW]

Public Class Methods

defaults() click to toggle source
# File lib/site_hook/config.rb, line 221
def self.defaults
  {
    app: "info",
    hook: "info",
    build: "info",
    git: "info",
  }
end
new(config) click to toggle source
# File lib/site_hook/config.rb, line 190
def initialize(config)
  LogLevels.defaults.each do |type, level|
    if config.fetch(type.to_s, nil)
      level(type.to_s, config.fetch(type.to_s))
    else
      level(type.to_s, level)
    end
  end
end

Public Instance Methods

fetch(key) click to toggle source
# File lib/site_hook/config.rb, line 217
def fetch(key)
  instance_variable_get(:"@#{key}")
end
inspect() click to toggle source
# File lib/site_hook/config.rb, line 209
def inspect
  levels = []
  instance_variables.each do |var|
    levels << "#{StrExt.rematvar(var)}=#{self.instance_variable_get(var)}"
  end
  "#<SiteHook::LogLevels #{levels.join(" ")}>"
end
level(type, level) click to toggle source
# File lib/site_hook/config.rb, line 230
def level(type, level)
  instance_variable_set(:"@#{type}", level)
end
to_h() click to toggle source
# File lib/site_hook/config.rb, line 200
def to_h
  output_hash = {}
  wanted = %i[app hook build git]
  wanted.each do |logger|
    output_hash.store(logger, instance_variable_get(StrExt.mkatvar(logger)))
  end
  output_hash
end