class Batsir::Notifiers::ConditionalNotifier

Constants

NotifierCondition

Attributes

notifiers[RW]

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method
# File lib/batsir/notifiers/conditional_notifier.rb, line 8
def initialize(options = {})
  super
  @notifiers = []
end

Public Instance Methods

add_notifier( condition, notifier_class, options = {}) click to toggle source
# File lib/batsir/notifiers/conditional_notifier.rb, line 13
def add_notifier( condition, notifier_class, options = {})
  self.notifiers << NotifierCondition.new(condition, notifier_class, options)
end
execute(message) click to toggle source
# File lib/batsir/notifiers/conditional_notifier.rb, line 17
def execute(message)
  self.notifiers.each do |notifier_condition|
    if notifier_condition.condition.call(message)
      notifier = notifier_condition.notifier
      options  = notifier_condition.options
      notifier.notify(message)
    end
  end
  message
end