Class: SendGrid::Section

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Section.



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

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

Instance Attribute Details

#sectionObject

Returns the value of attribute section.



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

def section
  @section
end

Instance Method Details

#to_jsonObject



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

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