Module: Kameleoon::Cookie Private
- Included in:
- Client
- Defined in:
- lib/kameleoon/cookie.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #check_visitor_code(visitor_code) ⇒ Object private
- #obtain_hash_double(visitor_code, respool_times = {}, container_id = '') ⇒ Object private
- #obtain_hash_double_helper(visitor_code, respool_times, container_id, suffix) ⇒ Object private
- #obtain_hash_double_rule(visitor_code, container_id = '', suffix = '') ⇒ Object private
-
#read_and_write(request_cookies, top_level_domain, response_cookies, default_visitor_code = nil) ⇒ String
private
Visitor code.
Instance Method Details
#check_visitor_code(visitor_code) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 44 45 46 47 |
# File 'lib/kameleoon/cookie.rb', line 41 def check_visitor_code(visitor_code) if visitor_code.nil? check_default_visitor_code('') elsif check_default_visitor_code(visitor_code) end end |
#obtain_hash_double(visitor_code, respool_times = {}, container_id = '') ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 |
# File 'lib/kameleoon/cookie.rb', line 25 def obtain_hash_double(visitor_code, respool_times = {}, container_id = '') obtain_hash_double_helper(visitor_code, respool_times, container_id, '') end |
#obtain_hash_double_helper(visitor_code, respool_times, container_id, suffix) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 38 39 |
# File 'lib/kameleoon/cookie.rb', line 33 def obtain_hash_double_helper(visitor_code, respool_times, container_id, suffix) identifier = visitor_code.to_s identifier += container_id.to_s identifier += suffix.to_s identifier += respool_times.sort.to_h.values.join.to_s if !respool_times.nil? && !respool_times.empty? (Digest::SHA256.hexdigest(identifier.encode('UTF-8')).to_i(16) / (BigDecimal('2')**BigDecimal('256'))).round(16) end |
#obtain_hash_double_rule(visitor_code, container_id = '', suffix = '') ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/kameleoon/cookie.rb', line 29 def obtain_hash_double_rule(visitor_code, container_id = '', suffix = '') obtain_hash_double_helper(visitor_code, {}, container_id, suffix) end |
#read_and_write(request_cookies, top_level_domain, response_cookies, default_visitor_code = nil) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns visitor code.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/kameleoon/cookie.rb', line 12 def read_and_write(, top_level_domain, , default_visitor_code = nil) kameleoon_visitor_code = read() if kameleoon_visitor_code.nil? kameleoon_visitor_code = check_default_visitor_code(default_visitor_code) || Kameleoon::Utils.generate_random_string(KAMELEOON_COOKIE_VALUE_LENGTH) end = { :value => kameleoon_visitor_code, :expires => Time.now + Kameleoon::Utils.in_seconds(EXPIRE_DAYS), :path => '/' } unless top_level_domain.nil? [:domain] = top_level_domain end [KAMELEOON_COOKIE_NAME] = kameleoon_visitor_code end |