# All plugins should include this module. It defines the basic # operations that all plugins are supposed to support. module Plugin def Plugin.included(c) # Callback, called whenever another class or module includes this # one. The parameter given is the name of the class or module # that included us. @includers ||= [] @includers << c end def Plugin.includers return @includers end def describe_domain(domain) # Provide a "description" of the domain. This is output along # with the domain name and can be anything of use to the system # administrator. raise NotImplementedError end def describe_account(account) # Provide a "description" of the account. This is output along # with the domain name and can be anything of use to the system # administrator. raise NotImplementedError end def list_users() # Return a list of all users managed by this plugin. raise NotImplementedError end def list_domains_users(domains) # Get all usernames belonging to the given domains. If a username # ends in @example.com, it belongs to the domain example.com # # This uses a naive loop, but relies only on the existence of a # list_users() method which is guaranteed above. More efficient # implementations can usually be made within the plugin. domains_users = [] usernames = list_users(); domains.each do |d| matches = usernames.select do |username| username =~ /@#{d}$/ end domains_users += matches end return domains_users end end