Class: Mailee::Message
- Defined in:
- lib/mailee/active_resource.rb
Overview
The Message class is where the fun happens.
USAGE:
# Creating a message (still a draft):
= Mailee::Message.create :title => "TITLE", :subject => "SUBJ", :from_name => "NAME", :from_email => "[email protected]", :html => "<h1>Hello</h1>", :list_id => 666
# Sending tests. 33, 44 and 55 are contact's ids.
.test([33,44,55])
# Sending the message now ...
.ready
# ... or sending the message 10 days from now
.ready(10.days.from_now)
Writeable attributes:
:newsletter_id, :template_id, :list_id, :segment_id, :title, :subject, :from_name, :from_email, :reply_email, :html, :analytics
Class Method Summary collapse
Instance Method Summary collapse
- #human_status ⇒ Object
- #ready(date = nil, hour = 0) ⇒ Object
- #signature ⇒ Object
- #test(contacts) ⇒ Object
- #thumb(size = 'thumb') ⇒ Object
Class Method Details
.writeable_attributes ⇒ Object
110 111 112 |
# File 'lib/mailee/active_resource.rb', line 110 def self.writeable_attributes [:newsletter_id, :template_id, :list_id, :contacts, :segment_id, :title, :subject, :from_name, :from_email, :reply_email, :html, :analytics] end |
Instance Method Details
#human_status ⇒ Object
113 114 115 |
# File 'lib/mailee/active_resource.rb', line 113 def human_status ['','draft','sending','sent','generating'][status] end |
#ready(date = nil, hour = 0) ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/mailee/active_resource.rb', line 125 def ready date=nil, hour=0 if date && date.is_a?(Date) && date > Time.now put(:ready, :when => 'after', :after => {:date => date.strftime("%d/%m/%Y"), :hour => date.strftime('%H')}) else put(:ready, :when => 'now') end end |
#signature ⇒ Object
116 117 118 |
# File 'lib/mailee/active_resource.rb', line 116 def signature "#{from_name} <#{from_email}>" end |
#test(contacts) ⇒ Object
122 123 124 |
# File 'lib/mailee/active_resource.rb', line 122 def test contacts put(:test, :contacts => contacts) end |
#thumb(size = 'thumb') ⇒ Object
119 120 121 |
# File 'lib/mailee/active_resource.rb', line 119 def thumb(size='thumb') "http://assets.mailee.me/system/messages/#{id}/thumbs/#{size}/#{id}.png" end |