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/person.rb | |
parent | 3185e5d746abda1b7f42ecdbd74ec14359fda3bc (diff) | |
parent | fd23821950f0562a8995735105cd31fdc6d55933 (diff) |
merge
Diffstat (limited to 'lib/mauve/configuration_builders/person.rb')
-rw-r--r-- | lib/mauve/configuration_builders/person.rb | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/mauve/configuration_builders/person.rb b/lib/mauve/configuration_builders/person.rb new file mode 100644 index 0000000..1f2af71 --- /dev/null +++ b/lib/mauve/configuration_builders/person.rb @@ -0,0 +1,60 @@ +# encoding: UTF-8 +require 'object_builder' +require 'mauve/person' +require 'mauve/configuration_builder' + +module Mauve + module ConfigurationBuilders + + class Person < ObjectBuilder + + def builder_setup(username) + @result = Mauve::Person.new(username) + end + + is_block_attribute "urgent" + is_block_attribute "normal" + is_block_attribute "low" + + def all(&block); urgent(&block); normal(&block); low(&block); end + + def password (pwd) + @result.password = pwd.to_s + end + + def holiday_url (url) + @result.holiday_url = url.to_s + end + + def email(e) + @result.email = e.to_s + end + + def xmpp(x) + @result.xmpp = x.to_s + end + + def sms(x) + @result.sms = x.to_s + end + + def suppress_notifications_after(h) + raise ArgumentError.new("notification_threshold must be specified as e.g. (10 => 1.minute)") unless + h.kind_of?(Hash) && h.keys[0].kind_of?(Integer) && h.values[0].kind_of?(Integer) + @result.notification_thresholds[h.values[0]] = Array.new(h.keys[0]) + end + end + end + + class ConfigurationBuilder < ObjectBuilder + + is_builder "person", ConfigurationBuilders::Person + + def created_person(person) + name = person.username + raise BuildException.new("Duplicate person '#{name}'") if @result.people[name] + @result.people[person.username] = person + end + + end +end |