Class: SendGrid::Section

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Section.



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

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

Instance Method Details

#sectionObject



14
15
16
# File 'lib/sendgrid/helpers/mail/section.rb', line 14

def section
  @section
end

#section=(section) ⇒ Object



10
11
12
# File 'lib/sendgrid/helpers/mail/section.rb', line 10

def section=(section)
  @section = section
end

#to_jsonObject



18
19
20
21
22
# File 'lib/sendgrid/helpers/mail/section.rb', line 18

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