Class: Batsir::Notifiers::ConditionalNotifier
- Defined in:
- lib/batsir/notifiers/conditional_notifier.rb
Defined Under Namespace
Classes: NotifierCondition
Instance Attribute Summary collapse
-
#notifiers ⇒ Object
Returns the value of attribute notifiers.
Attributes inherited from Notifier
#field_mapping, #transformer_queue
Instance Method Summary collapse
- #add_notifier(condition, notifier_class, options = {}) ⇒ Object
- #execute(message) ⇒ Object
-
#initialize(options = {}) ⇒ ConditionalNotifier
constructor
A new instance of ConditionalNotifier.
Methods inherited from Notifier
#add_transformer, #notify, #transform
Constructor Details
#initialize(options = {}) ⇒ ConditionalNotifier
Returns a new instance of ConditionalNotifier.
8 9 10 11 |
# File 'lib/batsir/notifiers/conditional_notifier.rb', line 8 def initialize( = {}) super @notifiers = [] end |
Instance Attribute Details
#notifiers ⇒ Object
Returns the value of attribute notifiers.
4 5 6 |
# File 'lib/batsir/notifiers/conditional_notifier.rb', line 4 def notifiers @notifiers end |
Instance Method Details
#add_notifier(condition, notifier_class, options = {}) ⇒ Object
13 14 15 |
# File 'lib/batsir/notifiers/conditional_notifier.rb', line 13 def add_notifier( condition, notifier_class, = {}) self.notifiers << NotifierCondition.new(condition, notifier_class, ) end |
#execute(message) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/batsir/notifiers/conditional_notifier.rb', line 17 def execute() self.notifiers.each do |notifier_condition| if notifier_condition.condition.call() notifier = notifier_condition.notifier = notifier_condition. notifier.notify() end end end |