Class: MultiNotifier::Builder
- Inherits:
-
Object
- Object
- MultiNotifier::Builder
- Defined in:
- lib/multi_notifier/builder.rb
Instance Attribute Summary collapse
-
#adapters ⇒ Object
readonly
Returns the value of attribute adapters.
Instance Method Summary collapse
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #notify_all! ⇒ Object
- #use(type, configs = {}) ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
7 8 9 |
# File 'lib/multi_notifier/builder.rb', line 7 def initialize @adapters = [] end |
Instance Attribute Details
#adapters ⇒ Object (readonly)
Returns the value of attribute adapters.
5 6 7 |
# File 'lib/multi_notifier/builder.rb', line 5 def adapters @adapters end |
Instance Method Details
#notify_all! ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/multi_notifier/builder.rb', line 19 def notify_all! adapters.each do |adapter| begin adapter.notify! rescue => e puts "#{adapter.class.name} has error #{e.inspect}" end end end |
#use(type, configs = {}) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/multi_notifier/builder.rb', line 11 def use(type, configs = {}) require "multi_notifier/middlewares/#{type}" adapter = "MultiNotifier::Middlewares::#{type.to_s.classify}".constantize adapters << adapter.new(configs) adapter end |