diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-09-16 12:47:52 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-09-16 12:47:52 +0100 |
commit | 38e4d877abee3c8e40edd932057e2bf16ad01e13 (patch) | |
tree | d2201a1c18fbebec4e0594b81c27974057e886b2 /lib/mauve/configuration_builders/notification_method.rb | |
parent | f63d7076e52a8844f1cfe43e57330687d88e83b6 (diff) |
Big documentation update.
Diffstat (limited to 'lib/mauve/configuration_builders/notification_method.rb')
-rw-r--r-- | lib/mauve/configuration_builders/notification_method.rb | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/mauve/configuration_builders/notification_method.rb b/lib/mauve/configuration_builders/notification_method.rb index 1192078..9596587 100644 --- a/lib/mauve/configuration_builders/notification_method.rb +++ b/lib/mauve/configuration_builders/notification_method.rb @@ -1,27 +1,46 @@ require 'mauve/notifiers' require 'mauve/configuration_builder' -# encoding: UTF-8 module Mauve module ConfigurationBuilders class NotificationMethod < ObjectBuilder + # + # Set up the notification. Missing notifiers are caught via NameError in + # the ObjectBuilder#parse method. + # + # @param [String] name Name of the notifier + # def builder_setup(name) - @notification_type = name.capitalize + notifiers_base = Mauve::Notifiers + + @notifier_type = notifiers_base.const_get(name.capitalize) + @name = name provider("Default") end + # This allows use of multiple notification providers, e.g. in the case of + # SMS. + # + # Missing providers are caught via NameError in the ObjectBuilder#parse + # method. + # def provider(name) - notifiers_base = Mauve::Notifiers - notifiers_type = notifiers_base.const_get(@notification_type) - @provider_class = notifiers_type.const_get(name) + @provider_class = @notifier_type.const_get(name) end + # Returns the result for this builder, depending on the configuration + # def result @result ||= @provider_class.new(@name) end - + + # This catches all methods available for a provider, as needed. + # + # Missing methods / bad arguments etc. are caught in the + # ObjectBuilder#parse method, via NoMethodError. + # def method_missing(name, value=nil) if value result.send("#{name}=".to_sym, value) @@ -38,6 +57,9 @@ module Mauve class ConfigurationBuilder < ObjectBuilder is_builder "notification_method", ConfigurationBuilders::NotificationMethod + # Method called after a notification method has been created to check for duplicate names. + # + # @raise [BuildException] when a duplicate notification method is found. def created_notification_method(notification_method) name = notification_method.name raise BuildException.new("Duplicate notification '#{name}'") if @result.notification_methods[name] |