Class: Puppi::Notification
- Inherits:
-
Object
- Object
- Puppi::Notification
- Defined in:
- lib/puppi/notification.rb
Instance Attribute Summary collapse
-
#notify_methods ⇒ Object
readonly
Returns the value of attribute notify_methods.
Instance Method Summary collapse
-
#initialize(notifications, output) ⇒ Notification
constructor
A new instance of Notification.
- #validate_notifications_methods(notifications) ⇒ Object
Constructor Details
#initialize(notifications, output) ⇒ Notification
Returns a new instance of Notification.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/puppi/notification.rb', line 6 def initialize(notifications, output) @notify_methods = Array.new if notifications.empty? notifier = Puppi::Notifications::Stdout.new notifier.output(output) @notify_methods << 'stdout' return end @loader = Puppi::Loader.new validate_notifications_methods notifications notifications.each do |notification| notifier = Puppi::Notifications.class_eval(notification.capitalize).new if notifier.respond_to? 'output' notifier.output(output) @notify_methods << notification end end end |
Instance Attribute Details
#notify_methods ⇒ Object (readonly)
Returns the value of attribute notify_methods.
4 5 6 |
# File 'lib/puppi/notification.rb', line 4 def notify_methods @notify_methods end |
Instance Method Details
#validate_notifications_methods(notifications) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/puppi/notification.rb', line 26 def validate_notifications_methods (notifications) notifications.each do |notification| if !valid_method? notification raise "unknown notification method" end end end |