Class: EasyMail::Namespace

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion
Defined in:
lib/easy_mail/namespace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mailer, name, attributes = {}) ⇒ Namespace

Returns a new instance of Namespace.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/easy_mail/namespace.rb', line 8

def initialize(mailer, name, attributes = {})
  @name = (mailer.namespaces.map(&:name) + [name.to_s]).join("/")
  if mailer.namespaces.any?
    @to = attributes[:to] || mailer.namespaces[-1].to
    @bcc = attributes[:bcc] || mailer.namespaces[-1].bcc
    @from = attributes[:from] || mailer.namespaces[-1].from
    @subject = attributes[:subject] || mailer.namespaces[-1].subject
  else
    @to = attributes[:to] || mailer.default_to
    @bcc= attributes[:bcc] || mailer.default_bcc
    @from = attributes[:from] || mailer.default_from
    @subject = attributes[:subject] || mailer.default_subject
  end
end

Instance Attribute Details

#bccObject

Returns the value of attribute bcc.



6
7
8
# File 'lib/easy_mail/namespace.rb', line 6

def bcc
  @bcc
end

#fromObject

Returns the value of attribute from.



6
7
8
# File 'lib/easy_mail/namespace.rb', line 6

def from
  @from
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/easy_mail/namespace.rb', line 6

def name
  @name
end

#subjectObject

Returns the value of attribute subject.



6
7
8
# File 'lib/easy_mail/namespace.rb', line 6

def subject
  @subject
end

#toObject

Returns the value of attribute to.



6
7
8
# File 'lib/easy_mail/namespace.rb', line 6

def to
  @to
end