Class: Rad::Mailer::Letter

Inherits:
Object show all
Defined in:
lib/rad/mailer/_letter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(properties) ⇒ Letter

Returns a new instance of Letter.



6
7
8
9
10
# File 'lib/rad/mailer/_letter.rb', line 6

def initialize properties
  properties.each do |k, v|
    send "#{k}=", v
  end
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/rad/mailer/_letter.rb', line 4

def body
  @body
end

#fromObject

Returns the value of attribute from.



4
5
6
# File 'lib/rad/mailer/_letter.rb', line 4

def from
  @from
end

#subjectObject

Returns the value of attribute subject.



4
5
6
# File 'lib/rad/mailer/_letter.rb', line 4

def subject
  @subject
end

#toObject

Returns the value of attribute to.



4
5
6
# File 'lib/rad/mailer/_letter.rb', line 4

def to
  @to
end

Instance Method Details

#deliverObject



19
20
21
22
# File 'lib/rad/mailer/_letter.rb', line 19

def deliver
  validate!
  mailer.deliver self
end

#to_hashObject Also known as: to_h



24
25
26
# File 'lib/rad/mailer/_letter.rb', line 24

def to_hash
  {from: from, to: to, subject: subject, body: body}
end

#validate!Object



12
13
14
15
16
17
# File 'lib/rad/mailer/_letter.rb', line 12

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