Class: Macaco::Sender
- Inherits:
-
Object
- Object
- Macaco::Sender
- Defined in:
- lib/macaco/senders/sender.rb
Direct Known Subclasses
Instance Method Summary collapse
- #body_html(val = nil) ⇒ Object (also: #html)
- #body_text(val = nil) ⇒ Object (also: #text)
- #from(val = nil) ⇒ Object
- #hash_attributes(args) ⇒ Object
-
#initialize(*args, &block) ⇒ Sender
constructor
A new instance of Sender.
- #subject(val = nil) ⇒ Object
- #to(val = nil) ⇒ Object
-
#to_json ⇒ Object
helpers - could be split out?.
Constructor Details
#initialize(*args, &block) ⇒ Sender
Returns a new instance of Sender.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/macaco/senders/sender.rb', line 4 def initialize(*args, &block) @body_html = nil @body_text = nil @text = nil @to = [] @from = nil @subject = nil if args.first.is_a? Hash hash_attributes(args.first) end if block_given? instance_eval(&block) end self end |
Instance Method Details
#body_html(val = nil) ⇒ Object Also known as: html
46 47 48 49 |
# File 'lib/macaco/senders/sender.rb', line 46 def body_html(val = nil) return @body_html unless val @body_html ||= val end |
#body_text(val = nil) ⇒ Object Also known as: text
52 53 54 55 |
# File 'lib/macaco/senders/sender.rb', line 52 def body_text(val = nil) return @body_text unless val @body_text ||= val end |
#from(val = nil) ⇒ Object
36 37 38 39 |
# File 'lib/macaco/senders/sender.rb', line 36 def from(val = nil) return @from unless val @from ||= val end |
#hash_attributes(args) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/macaco/senders/sender.rb', line 23 def hash_attributes(args) to args[:to] from args[:from] subject args[:subject] body_html args[:body_html] body_text args[:body_text] end |
#subject(val = nil) ⇒ Object
41 42 43 44 |
# File 'lib/macaco/senders/sender.rb', line 41 def subject(val = nil) return @subject unless val @subject ||= val end |
#to(val = nil) ⇒ Object
31 32 33 34 |
# File 'lib/macaco/senders/sender.rb', line 31 def to(val = nil) return @to unless val @to << { email: val } end |
#to_json ⇒ Object
helpers - could be split out?
60 61 62 |
# File 'lib/macaco/senders/sender.rb', line 60 def to_json to_hash.to_json end |