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
111 112 113 |
# File 'lib/mailee/active_resource.rb', line 111 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
114 115 116 |
# File 'lib/mailee/active_resource.rb', line 114 def human_status ['','draft','sending','sent','generating'][status] end |
#ready(date = nil, hour = 0) ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/mailee/active_resource.rb', line 126 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
117 118 119 |
# File 'lib/mailee/active_resource.rb', line 117 def signature "#{from_name} <#{from_email}>" end |
#test(contacts) ⇒ Object
123 124 125 |
# File 'lib/mailee/active_resource.rb', line 123 def test contacts put(:test, :contacts => contacts) end |
#thumb(size = 'thumb') ⇒ Object
120 121 122 |
# File 'lib/mailee/active_resource.rb', line 120 def thumb(size='thumb') "http://assets.mailee.me/system/messages/#{id}/thumbs/#{size}/#{id}.png" end |