Class: SendGrid::Section

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

Instance Method Summary collapse

Constructor Details

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


498
499
500
501
# File 'lib/sendgrid/helpers/mail/mail.rb', line 498

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

Instance Method Details

#sectionObject


507
508
509
# File 'lib/sendgrid/helpers/mail/mail.rb', line 507

def section
  @section
end

#section=(section) ⇒ Object


503
504
505
# File 'lib/sendgrid/helpers/mail/mail.rb', line 503

def section=(section)
  @section = section
end

#to_jsonObject


511
512
513
514
515
# File 'lib/sendgrid/helpers/mail/mail.rb', line 511

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