Class: Courrier::Email::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/courrier/email/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Options

Returns a new instance of Options.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/courrier/email/options.rb', line 10

def initialize(options = {})
  @from = options.fetch(:from, nil)

  @to = options.fetch(:to, nil)
  @reply_to = options.fetch(:reply_to, nil)
  @cc = options.fetch(:cc, nil)
  @bcc = options.fetch(:bcc, nil)

  @subject = options.fetch(:subject, "")
  @text = options.fetch(:text, "")
  @html = options.fetch(:html, "")

  @auto_generate_text = options.fetch(:auto_generate_text, false)

  @layouts = Array(options[:layouts])

  raise Courrier::ArgumentError, "Recipient (`to`) is required" unless @to
  raise Courrier::ArgumentError, "Sender (`from`) is required" unless @from
end

Instance Attribute Details

#bccObject (readonly)

Returns the value of attribute bcc.



8
9
10
# File 'lib/courrier/email/options.rb', line 8

def bcc
  @bcc
end

#ccObject (readonly)

Returns the value of attribute cc.



8
9
10
# File 'lib/courrier/email/options.rb', line 8

def cc
  @cc
end

#fromObject (readonly)

Returns the value of attribute from.



8
9
10
# File 'lib/courrier/email/options.rb', line 8

def from
  @from
end

#reply_toObject (readonly)

Returns the value of attribute reply_to.



8
9
10
# File 'lib/courrier/email/options.rb', line 8

def reply_to
  @reply_to
end

#subjectObject (readonly)

Returns the value of attribute subject.



8
9
10
# File 'lib/courrier/email/options.rb', line 8

def subject
  @subject
end

#toObject (readonly)

Returns the value of attribute to.



8
9
10
# File 'lib/courrier/email/options.rb', line 8

def to
  @to
end

Instance Method Details

#htmlObject



32
# File 'lib/courrier/email/options.rb', line 32

def html = wrap(@html, with_layout: :html)

#textObject



30
# File 'lib/courrier/email/options.rb', line 30

def text = wrap(transformed_text, with_layout: :text)