Class: Kameleoon::CustomData
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Data
Instance Method Summary collapse
Methods inherited from Data
Constructor Details
#initialize(*args) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/kameleoon/data.rb', line 60 def initialize(*args) @instance = DataType::CUSTOM @sent = false unless args.empty? if args.length == 1 hash = args.first if hash["id"].nil? raise NotFoundError.new("id") end @id = hash["id"].to_s if hash["value"].nil? raise NotFoundError.new(hash["value"]) end @value = hash["value"] elsif args.length == 2 @id = args[0].to_s @value = args[1] end end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
53 54 55 |
# File 'lib/kameleoon/data.rb', line 53 def id @id end |
#value ⇒ Object
Returns the value of attribute value.
53 54 55 |
# File 'lib/kameleoon/data.rb', line 53 def value @value end |
Instance Method Details
#obtain_full_post_text_line ⇒ Object
81 82 83 84 85 |
# File 'lib/kameleoon/data.rb', line 81 def obtain_full_post_text_line to_encode = "[[\"" + @value.to_s.gsub("\"", "\\\"") + "\",1]]" nonce = Kameleoon::Utils.generate_random_string(NONCE_LENGTH) "eventType=customData&index=" + @id.to_s + "&valueToCount=" + encode(to_encode) + "&overwrite=true&nonce=" + nonce end |