diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:54 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-07-22 16:55:54 +0100 |
commit | 25b32914b72a5f709eca773f3511cc89c2e710c2 (patch) | |
tree | 4dab9e78e4c6b49220a837b38d463328c05e2983 /lib/mauve/configuration_builders/notification_method.rb | |
parent | 3185e5d746abda1b7f42ecdbd74ec14359fda3bc (diff) | |
parent | fd23821950f0562a8995735105cd31fdc6d55933 (diff) |
merge
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 + |