Class: SendGrid::Substitution

Inherits:
Object
  • Object
show all
Defined in:
lib/sendgrid/helpers/mail/substitution.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key: nil, value: nil) ⇒ Substitution

Returns a new instance of Substitution.


7
8
9
10
# File 'lib/sendgrid/helpers/mail/substitution.rb', line 7

def initialize(key: nil, value: nil)
  @substitution = {}
  key.nil? || value.nil? ? @substitution = nil : @substitution[key] = value
end

Instance Attribute Details

#substitutionObject

Returns the value of attribute substitution


5
6
7
# File 'lib/sendgrid/helpers/mail/substitution.rb', line 5

def substitution
  @substitution
end

Instance Method Details

#to_jsonObject


12
13
14
15
16
# File 'lib/sendgrid/helpers/mail/substitution.rb', line 12

def to_json(*)
  {
    'substitution' => substitution
  }.delete_if { |_, value| value.to_s.strip == '' }
end