X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mailshears.git;a=blobdiff_plain;f=lib%2Frm%2Frm_plugin.rb;h=fd0c541a44cb25ed7ffbe7e96db3c19b59426265;hp=fe938b128d200b1a10427cbff7cdde17c57bd4b8;hb=aebdf12adce2766e2957f88916fcae6374d4eb4b;hpb=c2737d4d972df30725e417bed0940fc8df8e88bd diff --git a/lib/rm/rm_plugin.rb b/lib/rm/rm_plugin.rb index fe938b1..fd0c541 100644 --- a/lib/rm/rm_plugin.rb +++ b/lib/rm/rm_plugin.rb @@ -15,15 +15,27 @@ module RmPlugin return RmDummyRunner end + def delete(target) + # A generic version of delete_user/delete_domain that + # dispatches base on the class of the target. + if target.is_a?(User) + return delete_user(target) + elsif target.is_a?(Domain) + return delete_domain(target) + else + raise NotImplementedError + end + end + def delete_domain(domain) # Delete the given domain. Some plugins don't have a concept of # domains, so just delete all users with a username that looks # like it's in the given domain. - usernames = list_domains_users([domain]) + users = list_domains_users([domain]) - raise NonexistentDomainError.new(domain) if usernames.empty? + raise NonexistentDomainError.new(domain.to_s()) if users.empty? - usernames.each do |u| + users.each do |u| delete_user(u) end end