Class: SendGrid::Header

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Header.


579
580
581
582
# File 'lib/sendgrid/helpers/mail/mail.rb', line 579

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

Instance Method Details

#headerObject


588
589
590
# File 'lib/sendgrid/helpers/mail/mail.rb', line 588

def header
  @header
end

#header=(header) ⇒ Object


584
585
586
# File 'lib/sendgrid/helpers/mail/mail.rb', line 584

def header=(header)
  @header = header
end

#to_jsonObject


592
593
594
595
596
# File 'lib/sendgrid/helpers/mail/mail.rb', line 592

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