Class: SendGrid::CustomArg

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of CustomArg.



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

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

Instance Attribute Details

#custom_argObject

Returns the value of attribute custom_arg.



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

def custom_arg
  @custom_arg
end

Instance Method Details

#to_jsonObject



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

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