Class: MailManager::TestMessage
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- MailManager::TestMessage
show all
- Includes:
- StatusHistory
- Defined in:
- app/models/mail_manager/test_message.rb
Defined Under Namespace
Classes: Contact, Subscription
Class Method Summary
collapse
Instance Method Summary
collapse
#change_status, included, #set_default_status, #status, #status=, #status_changed_at=
Constructor Details
Returns a new instance of TestMessage.
15
16
17
18
|
# File 'app/models/mail_manager/test_message.rb', line 15
def initialize(*args)
super
set_type
end
|
Class Method Details
.valid_statuses ⇒ Object
101
102
103
|
# File 'app/models/mail_manager/test_message.rb', line 101
def self.valid_statuses
['pending','processing','sent','failed','ready']
end
|
Instance Method Details
78
79
80
|
# File 'app/models/mail_manager/test_message.rb', line 78
def contactable
contact.try(:contactable)
end
|
#default_status ⇒ Object
115
116
117
|
# File 'app/models/mail_manager/test_message.rb', line 115
def default_status
'pending'
end
|
#deliver ⇒ Object
sends the message through Mailer
#email_address ⇒ Object
59
60
61
|
# File 'app/models/mail_manager/test_message.rb', line 59
def email_address
contact.email_address
end
|
#email_address_with_name ⇒ Object
44
45
46
47
|
# File 'app/models/mail_manager/test_message.rb', line 44
def email_address_with_name
return %Q|"#{full_name}" <#{email_address}>|.gsub(/\s+/,' ') unless full_name.eql?('')
email_address
end
|
#from_email_address ⇒ Object
67
68
69
70
71
|
# File 'app/models/mail_manager/test_message.rb', line 67
def from_email_address
return self[:from_email_address] if self[:from_email_address].present?
self.update_attribute(:from_email_address,mailing.from_email_address)
self[:from_email_address]
end
|
#full_name ⇒ Object
55
56
57
|
# File 'app/models/mail_manager/test_message.rb', line 55
def full_name
contact.full_name
end
|
#generate_guid ⇒ Object
generated the guid for which the message is identified by in transit
110
111
112
113
|
# File 'app/models/mail_manager/test_message.rb', line 110
def generate_guid
update_attribute(:guid,
"#{contact.id}-#{subscription.try(:id)}-#{self.id}-#{Digest::SHA1.hexdigest("#{contact.id}-#{subscription.try(:id)}-#{self.id}-#{MailManager.secret}")}")
end
|
#parts ⇒ Object
returns the separate mime parts of the message’s Mailable
74
75
76
|
# File 'app/models/mail_manager/test_message.rb', line 74
def parts
@parts ||= mailing.parts(substitutions)
end
|
#subject ⇒ Object
63
64
65
|
# File 'app/models/mail_manager/test_message.rb', line 63
def subject
mailing.subject
end
|
#subscription ⇒ Object
138
139
140
|
# File 'app/models/mail_manager/test_message.rb', line 138
def subscription
Subscription.new(self)
end
|
#substitutions ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'app/models/mail_manager/test_message.rb', line 82
def substitutions
substitutions_hash = {}
MailManager::ContactableRegistry.registered_methods.each do |method|
method_key = method.to_s.upcase
if contact.respond_to?(method)
substitutions_hash[method_key] = contact.send(method)
elsif contactable.respond_to?(method)
substitutions_hash[method_key] = contactable.send(method)
else
substitutions_hash[method_key] = ''
end
end
substitutions_hash.merge('UNSUBSCRIBE_URL' => unsubscribe_url)
end
|
#unsubscribe_url ⇒ Object
97
98
99
|
# File 'app/models/mail_manager/test_message.rb', line 97
def unsubscribe_url
"#{MailManager.site_url}#{MailManager.unsubscribe_path}/#{guid}"
end
|
#valid_statuses ⇒ Object
105
106
107
|
# File 'app/models/mail_manager/test_message.rb', line 105
def valid_statuses
['pending','processing','sent','failed','ready']
end
|