Class: Voltron::Notification::EmailNotification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/voltron/notification/email_notification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attachmentsObject

Returns the value of attribute attachments.



17
18
19
# File 'app/models/voltron/notification/email_notification.rb', line 17

def attachments
  @attachments
end

#createdObject

Returns the value of attribute created.



19
20
21
# File 'app/models/voltron/notification/email_notification.rb', line 19

def created
  @created
end

#immediateObject

Returns the value of attribute immediate.



19
20
21
# File 'app/models/voltron/notification/email_notification.rb', line 19

def immediate
  @immediate
end

#varsObject

Returns the value of attribute vars.



17
18
19
# File 'app/models/voltron/notification/email_notification.rb', line 17

def vars
  @vars
end

Instance Method Details

#arguments(*args) ⇒ Object



51
52
53
# File 'app/models/voltron/notification/email_notification.rb', line 51

def arguments(*args)
  @mailer_arguments = *args
end

#attach(file, name = nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/voltron/notification/email_notification.rb', line 29

def attach(file, name = nil)
  name = File.basename(file) if name.blank?
  path = file

  if file.is_a?(File)
    path = file.path
    file.close
  elsif !File.exist?(path)
    path = Voltron.asset.find(path) || path
  end

  attachments[name] = path
end

#deliver_later(options = {}) ⇒ Object



71
72
73
74
# File 'app/models/voltron/notification/email_notification.rb', line 71

def deliver_later(options={})
  @mail_options = options
  @delivery_method = :deliver_later
end

#deliver_later!(options = {}) ⇒ Object



76
77
78
79
# File 'app/models/voltron/notification/email_notification.rb', line 76

def deliver_later!(options={})
  @mail_options = options
  @delivery_method = :deliver_later!
end

#deliver_nowObject



61
62
63
64
# File 'app/models/voltron/notification/email_notification.rb', line 61

def deliver_now
  @delivery_method = :deliver_now
  @immediate = true
end

#deliver_now!Object



66
67
68
69
# File 'app/models/voltron/notification/email_notification.rb', line 66

def deliver_now!
  @delivery_method = :deliver_now!
  @immediate = true
end

#mailer(klass = nil) ⇒ Object



43
44
45
# File 'app/models/voltron/notification/email_notification.rb', line 43

def mailer(klass = nil)
  self.mailer_class = (klass || mailer_class).to_s.classify.constantize
end

#method(meth = nil) ⇒ Object



47
48
49
# File 'app/models/voltron/notification/email_notification.rb', line 47

def method(meth = nil)
  self.mailer_method = (meth || mailer_method)
end

#requestObject



21
22
23
# File 'app/models/voltron/notification/email_notification.rb', line 21

def request
  Voltron::Notification.format_output_of(request_json)
end

#responseObject



25
26
27
# File 'app/models/voltron/notification/email_notification.rb', line 25

def response
  Voltron::Notification.format_output_of(response_json)
end

#template(fullpath) ⇒ Object



55
56
57
58
59
# File 'app/models/voltron/notification/email_notification.rb', line 55

def template(fullpath)
  parts = fullpath.split('/')
  self.template_name = parts.pop.sub(/\.[a-z_]+\.[^\.]+$/i, '')
  self.template_path = parts.join('/')
end