]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/common/plugin.rb
1 # All plugins should include this module. It defines the basic
2 # operations that all plugins are supposed to support.
6 # Callback, called whenever another class or module includes this
7 # one. The parameter given is the name of the class or module
17 def describe_domain(domain
)
18 # Provide a "description" of the domain. This is output along
19 # with the domain name and can be anything of use to the system
21 raise NotImplementedError
24 def describe_account(account
)
25 # Provide a "description" of the account. This is output along
26 # with the domain name and can be anything of use to the system
28 raise NotImplementedError
32 # Return a list of all users managed by this plugin.
33 raise NotImplementedError
36 def user_exists(username
)
37 # Does the given username exist for this plugin? We use a naive
38 # implementation here based on list_users() which is required to
39 # exist above. Plugins can override this with something fast.
41 return users
.include?(username
)
44 def list_domains_users(domains
)
45 # Get all usernames belonging to the given domains. If a username
46 # ends in @example.com, it belongs to the domain example.com
48 # This uses a naive loop, but relies only on the existence of a
49 # list_users() method which is guaranteed above. More efficient
50 # implementations can usually be made within the plugin.
53 usernames
= list_users();
55 matches
= usernames
.select
do |username
|
59 domains_users +
= matches