Class: SendGrid::Header

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Header.



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

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

Instance Attribute Details

#headerObject

Returns the value of attribute header.



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

def header
  @header
end

Instance Method Details

#to_jsonObject



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

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