Move domain removal into the plugins.
[mailshears.git] / lib / rm / rm_plugin.rb
1 module RmPlugin
2 #
3 # Plugins for the removal of accounts.
4 #
5
6 def RmPlugin.included(c)
7 # Callback, called whenever another class or module includes this
8 # one. The parameter given is the name of the class or module
9 # that included us.
10 @includers ||= []
11 @includers << c
12 end
13
14 def RmPlugin.includers
15 return @includers
16 end
17
18 def delete_domain(domain)
19 # Delete the given domain. Some plugins don't have a concept of
20 # domains, so just delete all users with a username that looks
21 # like it's in the given domain.
22 usernames = list_domains_users([domain])
23
24 raise NonexistentDomainError.new(domain) if usernames.empty?
25
26 usernames.each do |u|
27 delete_account(u)
28 end
29 end
30
31 def delete_account(account)
32 # Delete the given account.
33 raise NotImplementedError
34 end
35
36 end