class Noticent::Definitions::Alert::Notifier
holds a list of recipient + channel
Attributes
channel[R]
channel_group[R]
recipient[R]
template[R]
Public Class Methods
new(alert, recipient, template: '')
click to toggle source
# File lib/noticent/definitions/alert.rb, line 83 def initialize(alert, recipient, template: '') @recipient = recipient @alert = alert @config = alert.config @template = template @channel_group = :default @channel = nil end
Public Instance Methods
applicable_channels()
click to toggle source
returns an array of all channels this notifier should send to
# File lib/noticent/definitions/alert.rb, line 108 def applicable_channels if @channel_group == :_none_ # it's a single channel [@channel] else @config.channels_by_group(@channel_group) end end
on(channel_group_or_name)
click to toggle source
# File lib/noticent/definitions/alert.rb, line 92 def on(channel_group_or_name) # is it a group or a channel name? if @config.channel_groups.include? channel_group_or_name # it's a group @channel_group = channel_group_or_name @channel = nil elsif !@config.channels[channel_group_or_name].nil? @channel_group = :_none_ @channel = @config.channels[channel_group_or_name] else # not a group and not a channel raise ArgumentError, "no channel or channel group found named '#{channel_group_or_name}'" end end