Class: Rad::Letter
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#from ⇒ Object
Returns the value of attribute from.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #deliver ⇒ Object
-
#initialize(properties) ⇒ Letter
constructor
A new instance of Letter.
- #to_hash ⇒ Object (also: #to_h)
- #validate! ⇒ Object
Constructor Details
#initialize(properties) ⇒ Letter
Returns a new instance of Letter.
7 8 9 10 11 |
# File 'lib/rad/mail/letter.rb', line 7 def initialize properties properties.each do |k, v| send "#{k}=", v end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
5 6 7 |
# File 'lib/rad/mail/letter.rb', line 5 def body @body end |
#from ⇒ Object
Returns the value of attribute from.
5 6 7 |
# File 'lib/rad/mail/letter.rb', line 5 def from @from end |
#subject ⇒ Object
Returns the value of attribute subject.
5 6 7 |
# File 'lib/rad/mail/letter.rb', line 5 def subject @subject end |
#to ⇒ Object
Returns the value of attribute to.
5 6 7 |
# File 'lib/rad/mail/letter.rb', line 5 def to @to end |
Instance Method Details
#deliver ⇒ Object
20 21 22 23 |
# File 'lib/rad/mail/letter.rb', line 20 def deliver validate! mailer.deliver self end |
#to_hash ⇒ Object Also known as: to_h
25 26 27 |
# File 'lib/rad/mail/letter.rb', line 25 def to_hash {from: from, to: to, subject: subject, body: body} end |
#validate! ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rad/mail/letter.rb', line 13 def validate! from || raise("letter :from not specified!") to || raise("letter :to not specified!") subject || raise("letter :subject not specified!") body || raise("letter :body not specified!") end |