Class: SocketLabs::InjectionApi::Message::MergeData

Inherits:
Object
  • Object
show all
Defined in:
lib/socketlabs/injectionapi/message/merge_data.rb

Overview

Represents MergeData as a key and value pair. Example:

data1 = MergeData.new("key1", "value1")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key = nil, value = nil) ⇒ MergeData

Initializes a new instance of the CustomHeader class

Parameters:

  • key (String) (defaults to: nil)
  • value (String) (defaults to: nil)


21
22
23
24
25
26
27
# File 'lib/socketlabs/injectionapi/message/merge_data.rb', line 21

def initialize(
    key = nil,
    value = nil
)
  @key = key
  @value = value
end

Instance Attribute Details

#keyObject

the MergeData key



14
15
16
# File 'lib/socketlabs/injectionapi/message/merge_data.rb', line 14

def key
  @key
end

#valueObject

the value of the custom header



16
17
18
# File 'lib/socketlabs/injectionapi/message/merge_data.rb', line 16

def value
  @value
end

Instance Method Details

#is_validBoolean

A quick check to ensure that the MergeData is valid.

Returns:

  • (Boolean)


31
32
33
34
35
36
37
38
# File 'lib/socketlabs/injectionapi/message/merge_data.rb', line 31

def is_valid
  valid_key = StringExtension.is_nil_or_white_space(@key)
  valid_value = StringExtension.is_nil_or_white_space(@value)
  if valid_key && valid_value
    true
  end
  false
end

#to_sString

Represents the CustomHeader name-value pair as a String

Returns:

  • (String)


42
43
44
# File 'lib/socketlabs/injectionapi/message/merge_data.rb', line 42

def to_s
    "#{@name}, #{@value}"
end