Class: BMC::Email

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, ModelI18n, ModelToS
Defined in:
app/emails/bmc/email.rb

Constant Summary

Constants included from ModelI18n

ModelI18n::MissingTranslationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ModelI18n

#t, #ts, #tv

Methods included from ModelToS

#to_s

Constructor Details

#initializeEmail

Returns a new instance of Email.



23
24
25
26
# File 'app/emails/bmc/email.rb', line 23

def initialize(*)
  super
  assign_default_values
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



12
13
14
# File 'app/emails/bmc/email.rb', line 12

def body
  @body
end

#ccObject

Returns the value of attribute cc.



12
13
14
# File 'app/emails/bmc/email.rb', line 12

def cc
  @cc
end

#current_userObject

Returns the value of attribute current_user.



12
13
14
# File 'app/emails/bmc/email.rb', line 12

def current_user
  @current_user
end

#fromObject

Returns the value of attribute from.



12
13
14
# File 'app/emails/bmc/email.rb', line 12

def from
  @from
end

#reply_toObject

Returns the value of attribute reply_to.



12
13
14
# File 'app/emails/bmc/email.rb', line 12

def reply_to
  @reply_to
end

#subjectObject

Returns the value of attribute subject.



12
13
14
# File 'app/emails/bmc/email.rb', line 12

def subject
  @subject
end

#toObject

Returns the value of attribute to.



12
13
14
# File 'app/emails/bmc/email.rb', line 12

def to
  @to
end

Instance Method Details

#attachment_namesObject



28
29
30
# File 'app/emails/bmc/email.rb', line 28

def attachment_names
  attachments.keys.join(", ")
end

#dataObject



38
39
40
41
42
43
44
45
46
47
48
# File 'app/emails/bmc/email.rb', line 38

def data
  {
    :from        => from,
    :reply_to    => reply_to,
    :to          => to,
    :cc          => cc,
    :subject     => subject,
    :body        => body,
    :attachments => attachments,
  }
end

#deliverObject



50
51
52
# File 'app/emails/bmc/email.rb', line 50

def deliver
  deliver_now
end

#deliver_laterObject



58
59
60
# File 'app/emails/bmc/email.rb', line 58

def deliver_later
  BMC::GenericMailer.generic_email(data).deliver_later
end

#deliver_nowObject



54
55
56
# File 'app/emails/bmc/email.rb', line 54

def deliver_now
  BMC::GenericMailer.generic_email(data).deliver_now
end

#validate_and_deliverObject



32
33
34
35
36
# File 'app/emails/bmc/email.rb', line 32

def validate_and_deliver
  ok = valid?
  deliver if ok
  ok
end