Module: MList::List

Includes:
Callbacks
Included in:
Manager::Database::List
Defined in:
lib/mlist/list.rb

Overview

Represents the interface of the lists that a list manager must answer. This is distinct from the MList::MailList to allow for greater flexibility in processing email coming to a list - that is, whatever you include this into may re-define behavior appropriately.

Your ‘subscriber’ instances MUST respond to :email_address. They may optionally respond to :display_name.

Defined Under Namespace

Modules: Callbacks

Instance Method Summary collapse

Methods included from Callbacks

#blocked_subscriber_post, #bounce, #inactive_post, #non_subscriber_post

Instance Method Details

#active?Boolean

Answers whether this list is active or not. All lists are active all the time by default.

Returns:

  • (Boolean)


16
17
18
# File 'lib/mlist/list.rb', line 16

def active?
  true
end

#archive_urlObject

The web address where an archive of this list may be found, nil if there is no archive.



66
67
68
# File 'lib/mlist/list.rb', line 66

def archive_url
  nil
end

#blocked?(subscriber) ⇒ Boolean

Answers whether the subscriber is blocked from posting or not. This will not be asked when the list is not active (answers active? as false).

Returns:

  • (Boolean)


23
24
25
# File 'lib/mlist/list.rb', line 23

def blocked?(subscriber)
  false
end

Answers the footer content for this list. Default implementation is very simple right now. Expect improvements in the future.



30
31
32
# File 'lib/mlist/list.rb', line 30

def footer_content(message)
  %Q{The "#{label}" mailing list\nTo post messages, send email to #{post_url}}
end

#help_urlObject

The web address of the list help site, nil if this is not supported.



72
73
74
# File 'lib/mlist/list.rb', line 72

def help_url
  nil
end

#labelObject

Answer a suitable label for the list, which will be used in various parts of content that is delivered to subscribers, etc.



37
38
39
# File 'lib/mlist/list.rb', line 37

def label
  raise 'answer the list label'
end

#list_headersObject

Answers the headers that are to be included in the emails delivered for this list. Any entries that have a nil value will not be included in the delivered email.



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/mlist/list.rb', line 45

def list_headers
  {
    'list-id'          => list_id,
    'list-archive'     => archive_url,
    'list-subscribe'   => subscribe_url,
    'list-unsubscribe' => unsubscribe_url,
    'list-owner'       => owner_url,
    'list-help'        => help_url,
    'list-post'        => post_url
  }
end

#list_idObject

Answers a unique, never changing value for this list.



59
60
61
# File 'lib/mlist/list.rb', line 59

def list_id
  raise 'answer a unique, never changing value'
end

#owner_urlObject

The email address of the list owner, nil if this is not supported.



78
79
80
# File 'lib/mlist/list.rb', line 78

def owner_url
  nil
end

#post_urlObject

The email address where posts should be sent. Defaults to the address of the list.



85
86
87
# File 'lib/mlist/list.rb', line 85

def post_url
  address
end

#recipients(subscriber) ⇒ Object

A list is responsible for answering the recipient subscribers.

The subscriber of the incoming message is provided if the list would like to exclude it from the returned list. It is not assumed that it will be included or excluded, thereby allowing the list to decide. This default implementation does not include the sending subscriber in the list of recipients.



111
112
113
# File 'lib/mlist/list.rb', line 111

def recipients(subscriber)
  subscribers.reject {|s| s.email_address == subscriber.email_address}
end

#subscribe_urlObject

The web url where subscriptions to this list may be created, nil if this is not supported.



92
93
94
# File 'lib/mlist/list.rb', line 92

def subscribe_url
  nil
end

#subscriber(email_address) ⇒ Object

A list must answer the subscriber who’s email address is that of the one provided. The default implementation will pick the first instance that answers subscriber.email_address == email_address. Your implementation should probably select just one record.



120
121
122
# File 'lib/mlist/list.rb', line 120

def subscriber(email_address)
  subscribers.detect {|s| s.email_address == email_address}
end

#subscriber?(email_address) ⇒ Boolean

A list must answer whether there is a subscriber who’s email address is that of the one provided. This is checked before the subscriber is requested in order to allow for the lightest weight check possible; that is, your implementation could avoid loading the actual subscriber instance.

Returns:

  • (Boolean)


130
131
132
# File 'lib/mlist/list.rb', line 130

def subscriber?(email_address)
  !subscriber(email_address).nil?
end

#unsubscribe_urlObject

The web url where subscriptions to this list may be deleted, nil if this is not supported.



99
100
101
# File 'lib/mlist/list.rb', line 99

def unsubscribe_url
  nil
end