class Noticent::Config
Attributes
alerts[R]
channel_groups[R]
channels[R]
hooks[R]
products[R]
scopes[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/noticent/config.rb, line 67 def initialize(options = {}) @options = options @products = {} end
Public Instance Methods
alert_channels(alert_name)
click to toggle source
# File lib/noticent/config.rb, line 78 def alert_channels(alert_name) alert = @alerts[alert_name] raise ArgumentError, "no alert #{alert_name} found" if alert.nil? return [] if alert.notifiers.nil? alert.notifiers.values.collect { |notifier| channels_by_group(notifier.channel_group).uniq }.uniq.flatten end
alerts_by_scope(scope)
click to toggle source
# File lib/noticent/config.rb, line 93 def alerts_by_scope(scope) return [] if @alerts.nil? @alerts.values.select { |x| x.scope.name == scope } end
base_dir()
click to toggle source
# File lib/noticent/config.rb, line 99 def base_dir @options[:base_dir] end
base_module_name()
click to toggle source
# File lib/noticent/config.rb, line 103 def base_module_name @options[:base_module_name] end
channel_dir()
click to toggle source
# File lib/noticent/config.rb, line 139 def channel_dir File.join(base_dir, "channels") end
channels_by_group(group)
click to toggle source
# File lib/noticent/config.rb, line 72 def channels_by_group(group) return [] if @channels.nil? @channels.values.select { |x| x.group == group } end
create_dynamics()
click to toggle source
# File lib/noticent/config.rb, line 147 def create_dynamics return if alerts.nil? alerts.keys.each do |alert| const_name = "ALERT_#{alert.to_s.upcase}" next if Noticent.const_defined?(const_name) Noticent.const_set(const_name, alert) end end
default_value()
click to toggle source
# File lib/noticent/config.rb, line 123 def default_value @options[:default_value].nil? ? false : @options[:default_value] end
halt_on_error()
click to toggle source
# File lib/noticent/config.rb, line 115 def halt_on_error @options[:halt_on_error].nil? ? false : @options[:halt_on_error] end
logger()
click to toggle source
# File lib/noticent/config.rb, line 111 def logger @options[:logger] || Logger.new(STDOUT) end
opt_in_provider()
click to toggle source
# File lib/noticent/config.rb, line 107 def opt_in_provider @options[:opt_in_provider] || Noticent::ActiveRecordOptInProvider.new end
payload_dir()
click to toggle source
# File lib/noticent/config.rb, line 131 def payload_dir File.join(base_dir, "payloads") end
products_by_alert(alert_name)
click to toggle source
# File lib/noticent/config.rb, line 86 def products_by_alert(alert_name) alert = @alerts[alert_name] raise ArgumentError, "no alert #{alert_name} found" if alert.nil? alert.products end
scope_dir()
click to toggle source
# File lib/noticent/config.rb, line 135 def scope_dir File.join(base_dir, "scopes") end
skip_alert_with_no_subscribers()
click to toggle source
# File lib/noticent/config.rb, line 119 def skip_alert_with_no_subscribers @options[:skip_alert_with_no_subscribers].nil? ? false : @options[:skip_alert_with_no_subscribers] end
use_sub_modules()
click to toggle source
# File lib/noticent/config.rb, line 127 def use_sub_modules @options[:use_sub_modules].nil? ? false : @options[:use_sub_modules] end
validate!()
click to toggle source
# File lib/noticent/config.rb, line 158 def validate! # check all scopes scopes&.values&.each(&:validate!) alerts&.values&.each(&:validate!) end
view_dir()
click to toggle source
# File lib/noticent/config.rb, line 143 def view_dir File.join(base_dir, "views") end