]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/rm/rm_plugin.rb
1 require 'common/plugin.rb'
4 # Plugins for the removal of users and domains.
8 # Absorb the subclass run() magic from the Plugin::Run module.
11 # The runner class associated with removal plugins.
13 # @return [Class] the {RmRunner} class.
20 # The "dummy" runner class associated with removal plugins.
22 # @return [Class] the {RmDummyRunner} class.
24 def self.dummy_runner()
29 # Remove the *target* domain or user. This is a generic version of
30 # the {#remove_user} and {#remove_domain} operations that will
31 # dispatch based on the type of *target*.
33 # @param target [User,Domain] the user or domain to remove.
36 # A generic version of remove_user/remove_domain that
37 # dispatches base on the class of the target.
39 return remove_user(target
)
40 elsif target
.is_a
?(Domain
)
41 return remove_domain(target
)
43 raise NotImplementedError
48 # Remove the given *domain*. Some plugins don't have a concept of
49 # domains, so the default implementation here removes all users that
50 # look like they belong to *domain*. Subclasses can be smarter.
52 # @param domain [Domain] the domain to remove.
54 def remove_domain(domain
)
55 users
= list_domains_users([domain
])
57 # It's possible for a domain to exist with no users, but this
58 # default implementation is based on the assumption that it should
59 # work for plugins having no "domain" concept.
60 raise NonexistentDomainError
.new(domain
.to_s()) if users
.empty
?
68 # The interface for the "remove a user" operation. Subclasses
69 # need to implement this method so that it removes *user*.
71 # @param user [User] the user to remove.
74 raise NotImplementedError