Class: SendGrid::Recipient
- Inherits:
-
Object
- Object
- SendGrid::Recipient
- Defined in:
- lib/sendgrid/recipient.rb
Defined Under Namespace
Classes: NoAddress
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#substitutions ⇒ Object
readonly
Returns the value of attribute substitutions.
Instance Method Summary collapse
- #add_substitution(key, value) ⇒ Object
- #add_to_smtpapi(smtpapi) ⇒ Object
-
#initialize(address) ⇒ Recipient
constructor
A new instance of Recipient.
Constructor Details
#initialize(address) ⇒ Recipient
Returns a new instance of Recipient.
9 10 11 12 13 14 |
# File 'lib/sendgrid/recipient.rb', line 9 def initialize(address) @address = address @substitutions = {} raise NoAddress, 'Recipient address cannot be nil' if @address.nil? end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
7 8 9 |
# File 'lib/sendgrid/recipient.rb', line 7 def address @address end |
#substitutions ⇒ Object (readonly)
Returns the value of attribute substitutions.
7 8 9 |
# File 'lib/sendgrid/recipient.rb', line 7 def substitutions @substitutions end |
Instance Method Details
#add_substitution(key, value) ⇒ Object
16 17 18 |
# File 'lib/sendgrid/recipient.rb', line 16 def add_substitution(key, value) substitutions[key] = value end |
#add_to_smtpapi(smtpapi) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/sendgrid/recipient.rb', line 20 def add_to_smtpapi(smtpapi) smtpapi.add_to(@address) @substitutions.each do |key, value| existing = smtpapi.sub[key] || [] smtpapi.add_substitution(key, existing + [value]) end end |