Class: MailManager::Message
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- MailManager::Message
show all
- Includes:
- StatusHistory
- Defined in:
- app/models/mail_manager/message.rb
Instance Method Summary
collapse
#change_status, included, #set_default_status, #status, #status=, #status_changed_at=
Constructor Details
#initialize(*args) ⇒ Message
Returns a new instance of Message.
33
34
35
36
|
# File 'app/models/mail_manager/message.rb', line 33
def initialize(*args)
super
set_type
end
|
Instance Method Details
93
94
95
|
# File 'app/models/mail_manager/message.rb', line 93
def contactable
contact.try(:contactable)
end
|
#deliver ⇒ Object
sends the message through Mailer
#email_address ⇒ Object
74
75
76
|
# File 'app/models/mail_manager/message.rb', line 74
def email_address
contact.email_address
end
|
#email_address_with_name ⇒ Object
59
60
61
62
|
# File 'app/models/mail_manager/message.rb', line 59
def email_address_with_name
return %Q|"#{full_name}" <#{email_address}>|.gsub(/\s+/,' ') unless full_name.eql?('')
email_address
end
|
#from_email_address ⇒ Object
82
83
84
85
86
|
# File 'app/models/mail_manager/message.rb', line 82
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
70
71
72
|
# File 'app/models/mail_manager/message.rb', line 70
def full_name
contact.full_name
end
|
#generate_guid ⇒ Object
generated the guid for which the message is identified by in transit
117
118
119
120
|
# File 'app/models/mail_manager/message.rb', line 117
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
89
90
91
|
# File 'app/models/mail_manager/message.rb', line 89
def parts
@parts ||= mailing.parts(substitutions)
end
|
#subject ⇒ Object
78
79
80
|
# File 'app/models/mail_manager/message.rb', line 78
def subject
mailing.subject
end
|
#substitutions ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'app/models/mail_manager/message.rb', line 97
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
112
113
114
|
# File 'app/models/mail_manager/message.rb', line 112
def unsubscribe_url
"#{MailManager.site_url}#{MailManager.unsubscribe_path}/#{guid}"
end
|