Class: Pushpop::Sendgrid
- Inherits:
-
Step
- Object
- Step
- Pushpop::Sendgrid
- Defined in:
- lib/pushpop-sendgrid.rb,
lib/pushpop-sendgrid/version.rb
Constant Summary collapse
- PLUGIN_NAME =
'sendgrid'- VERSION =
'0.1.2'
Instance Attribute Summary collapse
-
#_attachment ⇒ Object
Returns the value of attribute _attachment.
-
#_body ⇒ Object
Returns the value of attribute _body.
-
#_from ⇒ Object
Returns the value of attribute _from.
-
#_preview ⇒ Object
Returns the value of attribute _preview.
-
#_subject ⇒ Object
Returns the value of attribute _subject.
-
#_to ⇒ Object
Returns the value of attribute _to.
Instance Method Summary collapse
- #attachment(_attachment) ⇒ Object
- #body(*args) ⇒ Object
- #configure(last_response = nil, step_responses = nil) ⇒ Object
- #from(from) ⇒ Object
- #preview(preview) ⇒ Object
- #run(last_response = nil, step_responses = nil) ⇒ Object
- #send_email(_to, _from, _subject, _body, _attachment) ⇒ Object
- #subject(subject) ⇒ Object
- #to(to) ⇒ Object
Instance Attribute Details
#_attachment ⇒ Object
Returns the value of attribute _attachment.
27 28 29 |
# File 'lib/pushpop-sendgrid.rb', line 27 def @_attachment end |
#_body ⇒ Object
Returns the value of attribute _body.
25 26 27 |
# File 'lib/pushpop-sendgrid.rb', line 25 def _body @_body end |
#_from ⇒ Object
Returns the value of attribute _from.
22 23 24 |
# File 'lib/pushpop-sendgrid.rb', line 22 def _from @_from end |
#_preview ⇒ Object
Returns the value of attribute _preview.
26 27 28 |
# File 'lib/pushpop-sendgrid.rb', line 26 def _preview @_preview end |
#_subject ⇒ Object
Returns the value of attribute _subject.
24 25 26 |
# File 'lib/pushpop-sendgrid.rb', line 24 def _subject @_subject end |
#_to ⇒ Object
Returns the value of attribute _to.
23 24 25 |
# File 'lib/pushpop-sendgrid.rb', line 23 def _to @_to end |
Instance Method Details
#attachment(_attachment) ⇒ Object
91 92 93 |
# File 'lib/pushpop-sendgrid.rb', line 91 def () self. = end |
#body(*args) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/pushpop-sendgrid.rb', line 83 def body(*args) if args.length == 1 self._body = args.first else self._body = template(*args) end end |
#configure(last_response = nil, step_responses = nil) ⇒ Object
63 64 65 |
# File 'lib/pushpop-sendgrid.rb', line 63 def configure(last_response=nil, step_responses=nil) self.instance_exec(last_response, step_responses, &block) end |
#from(from) ⇒ Object
67 68 69 |
# File 'lib/pushpop-sendgrid.rb', line 67 def from(from) self._from = from end |
#preview(preview) ⇒ Object
79 80 81 |
# File 'lib/pushpop-sendgrid.rb', line 79 def preview(preview) self._preview = preview end |
#run(last_response = nil, step_responses = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pushpop-sendgrid.rb', line 29 def run(last_response=nil, step_responses=nil) self.configure(last_response, step_responses) # print the message if its just a preview return print_preview if self._preview _to = self._to _from = self._from _subject = self._subject _body = self._body = self. if _to && _from && _subject && _body send_email(_to, _from, _subject, _body, ) end end |
#send_email(_to, _from, _subject, _body, _attachment) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pushpop-sendgrid.rb', line 47 def send_email(_to, _from, _subject, _body, ) Mail.deliver do to _to from _from subject _subject add_file if text_part do body _body end html_part do content_type 'text/html; charset=UTF-8' body _body end end end |
#subject(subject) ⇒ Object
75 76 77 |
# File 'lib/pushpop-sendgrid.rb', line 75 def subject(subject) self._subject = subject end |
#to(to) ⇒ Object
71 72 73 |
# File 'lib/pushpop-sendgrid.rb', line 71 def to(to) self._to = to end |