lib/mailgun/messages/message_builder.rb
def variable(name, data)
      fail(Mailgun::ParameterError, 'Variable name must be specified') if name.to_s.empty?
      begin
        jsondata = make_json data
        set_single("v:#{name}", jsondata)
      rescue Mailgun::ParameterError
        set_single("v:#{name}", data)
      end
    end
# Attaches custom JSON data to the message. See the following doc page for more info.
# https://documentation.mailgun.com/user_manual.html#attaching-data-to-messages
#
# @param [String] name A name for the custom variable block.
# @param [String|Hash] data Either a string or a hash. If it is not valid JSON or
#                           can not be converted to JSON, ParameterError will be raised.
# @return [void]
Attaches custom JSON data to the message. See the following doc page for more info.
Attaches custom JSON data to the message . See the following doc page for more info .
def variable(name, data)
      fail(Mailgun::ParameterError, 'Variable name must be specified') if name.to_s.empty?
      begin
        jsondata = make_json data
        set_single("v:#{name}", jsondata)
      rescue Mailgun::ParameterError
        set_single("v:#{name}", data)
      end
    end
def variable ( name , data ) fail ( Mailgun :: ParameterError , 'Variable name must be specified' ) if name . to_s . empty? begin jsondata = make_json data set_single ( "v:#{name}" , jsondata ) rescue Mailgun :: ParameterError set_single ( "v:#{name}" , data ) end end
Attaches custom JSON data to the message.
Attaches custom JSON data to the message .
None
void
name
data
data Either a string or a hash. If it is not valid JSON or can not be converted to JSON, ParameterError will be raised.
data Either a string or a hash . If it is not valid JSON or can not be converted to JSON ParameterError will be raised .