diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:01 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:01 +0100 |
commit | fd23821950f0562a8995735105cd31fdc6d55933 (patch) | |
tree | 967df2f5647803a6c46f4d52003b2231c1de72cb /lib/mauve/configuration_builders/notification_method.rb | |
parent | d3a3cfef9650b08f62db62bd7e86b673f9d77d0b (diff) |
* Rejigged configuration
* Added --test and --verbose flags for the server config
* Started proper test suite
* Config parsing now gives more sensible errors + backtrace
* Rejigged people and source lists
Diffstat (limited to 'lib/mauve/configuration_builders/notification_method.rb')
-rw-r--r-- | lib/mauve/configuration_builders/notification_method.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/mauve/configuration_builders/notification_method.rb b/lib/mauve/configuration_builders/notification_method.rb new file mode 100644 index 0000000..1192078 --- /dev/null +++ b/lib/mauve/configuration_builders/notification_method.rb @@ -0,0 +1,50 @@ +require 'mauve/notifiers' +require 'mauve/configuration_builder' + +# encoding: UTF-8 +module Mauve + module ConfigurationBuilders + class NotificationMethod < ObjectBuilder + + def builder_setup(name) + @notification_type = name.capitalize + @name = name + provider("Default") + end + + def provider(name) + notifiers_base = Mauve::Notifiers + notifiers_type = notifiers_base.const_get(@notification_type) + @provider_class = notifiers_type.const_get(name) + end + + def result + @result ||= @provider_class.new(@name) + end + + def method_missing(name, value=nil) + if value + result.send("#{name}=".to_sym, value) + else + result.send(name.to_sym) + end + end + end + end + + # + # Add notification_method to our top-level config builder + # + class ConfigurationBuilder < ObjectBuilder + is_builder "notification_method", ConfigurationBuilders::NotificationMethod + + def created_notification_method(notification_method) + name = notification_method.name + raise BuildException.new("Duplicate notification '#{name}'") if @result.notification_methods[name] + @result.notification_methods[name] = notification_method + end + + end + +end + |