Class: Smailer::Models::MailCampaign
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Smailer::Models::MailCampaign
show all
- Defined in:
- lib/smailer/models/mail_campaign.rb
Defined Under Namespace
Classes: UnsubscribeMethods
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.unsubscribe_methods ⇒ Object
68
69
70
71
72
73
74
75
|
# File 'lib/smailer/models/mail_campaign.rb', line 68
def self.unsubscribe_methods
methods = {}
UnsubscribeMethods.constants.map do |method_name|
methods[UnsubscribeMethods.const_get(method_name)] = method_name
end
methods
end
|
Instance Method Details
#active_unsubscribe_methods ⇒ Object
45
46
47
48
49
|
# File 'lib/smailer/models/mail_campaign.rb', line 45
def active_unsubscribe_methods
self.class.unsubscribe_methods.reject do |method, method_name|
not has_unsubscribe_method?(method)
end
end
|
#add_attachment(filename, path) ⇒ Object
64
65
66
|
# File 'lib/smailer/models/mail_campaign.rb', line 64
def add_attachment(filename, path)
my_mail_template.attachments.build(:filename => filename, :path => path)
end
|
#add_unsubscribe_method(method_specification) ⇒ Object
27
28
29
30
31
|
# File 'lib/smailer/models/mail_campaign.rb', line 27
def add_unsubscribe_method(method_specification)
unsubscribe_methods_list_from(method_specification).each do |method|
self.unsubscribe_methods = (self.unsubscribe_methods || 0) | method
end
end
|
#attachments ⇒ Object
60
61
62
|
# File 'lib/smailer/models/mail_campaign.rb', line 60
def attachments
my_mail_template.attachments
end
|
#has_unsubscribe_method?(method) ⇒ Boolean
41
42
43
|
# File 'lib/smailer/models/mail_campaign.rb', line 41
def has_unsubscribe_method?(method)
(unsubscribe_methods || 0) & method === method
end
|
#hit_rate ⇒ Object
55
56
57
58
|
# File 'lib/smailer/models/mail_campaign.rb', line 55
def hit_rate
return nil if sent_mails_count == 0
opened_mails_count.to_f / sent_mails_count
end
|
#name ⇒ Object
51
52
53
|
# File 'lib/smailer/models/mail_campaign.rb', line 51
def name
"Campaign ##{id} (#{mailing_list.name})"
end
|
#remove_unsubscribe_method(method_specification) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/smailer/models/mail_campaign.rb', line 33
def remove_unsubscribe_method(method_specification)
unsubscribe_methods_list_from(method_specification).each do |method|
if has_unsubscribe_method?(method)
self.unsubscribe_methods = (self.unsubscribe_methods || 0) ^ method
end
end
end
|