Class: Kameleoon::CustomData
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Attributes inherited from Data
Instance Method Summary collapse
Methods inherited from Data
Constructor Details
#initialize(arg0, *args) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/kameleoon/data.rb', line 62 def initialize(arg0, *args) @instance = DataType::CUSTOM @sent = false if arg0.is_a?(Hash) hash = arg0 id = hash['id'] raise Kameleoon::Exception::NotFound.new('id') if id.nil? @id = id.to_s value = hash['value'] values = hash['values'] raise Kameleoon::Exception::NotFound.new('values') if values.nil? && value.nil? if values.nil? @values = [value] else @values = values.dup @values.append(value) unless value.nil? end else @id = arg0.to_s @values = args end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
55 56 57 |
# File 'lib/kameleoon/data.rb', line 55 def id @id end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
55 56 57 |
# File 'lib/kameleoon/data.rb', line 55 def values @values end |
Instance Method Details
#obtain_full_post_text_line ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/kameleoon/data.rb', line 85 def obtain_full_post_text_line return '' if @values.empty? str_values = "[[\"#{@values.join('",1],["')}\",1]]" nonce = Kameleoon::Utils.generate_random_string(NONCE_LENGTH) "eventType=customData&index=#{@id}&valueToCount=#{encode(str_values)}&overwrite=true&nonce=#{nonce}" end |