Class: SendGrid::Substitution

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Substitution.


600
601
602
603
# File 'lib/sendgrid/helpers/mail/mail.rb', line 600

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

Instance Method Details

#substitutionObject


609
610
611
# File 'lib/sendgrid/helpers/mail/mail.rb', line 609

def substitution
  @substitution
end

#substitution=(substitution) ⇒ Object


605
606
607
# File 'lib/sendgrid/helpers/mail/mail.rb', line 605

def substitution=(substitution)
  @substitution = substitution
end

#to_jsonObject


613
614
615
616
617
# File 'lib/sendgrid/helpers/mail/mail.rb', line 613

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