Class: Kameleoon::DataManager::AssignedVariation

Inherits:
Kameleoon::DuplicationUnsafeData show all
Defined in:
lib/kameleoon/data/manager/assigned_variation.rb

Overview

AssignedVariation represents a variation assigned to a visitor.

Constant Summary collapse

EVENT_TYPE =
'experiment'

Instance Attribute Summary collapse

Attributes inherited from Kameleoon::Data

#instance

Instance Method Summary collapse

Methods inherited from Kameleoon::Data

#mark_as_sent, #mark_as_transmitting, #mark_as_unsent, #sent, #transmitting, #unsent

Constructor Details

#initialize(experiment_id, variation_id, rule_type = Kameleoon::Configuration::RuleType::UNKNOWN, assignment_time: nil) ⇒ AssignedVariation

Returns a new instance of AssignedVariation.



21
22
23
24
25
26
27
28
29
# File 'lib/kameleoon/data/manager/assigned_variation.rb', line 21

def initialize(
  experiment_id, variation_id, rule_type = Kameleoon::Configuration::RuleType::UNKNOWN, assignment_time: nil
)
  super(DataType::ASSIGNED_VARIATION)
  @experiment_id = experiment_id
  @variation_id = variation_id
  @rule_type = rule_type
  @assignment_time = assignment_time || Time.new.to_i
end

Instance Attribute Details

#assignment_timeObject (readonly)

Returns the value of attribute assignment_time.



14
15
16
# File 'lib/kameleoon/data/manager/assigned_variation.rb', line 14

def assignment_time
  @assignment_time
end

#experiment_idObject (readonly)

Returns the value of attribute experiment_id.



14
15
16
# File 'lib/kameleoon/data/manager/assigned_variation.rb', line 14

def experiment_id
  @experiment_id
end

#rule_typeObject (readonly)

Returns the value of attribute rule_type.



14
15
16
# File 'lib/kameleoon/data/manager/assigned_variation.rb', line 14

def rule_type
  @rule_type
end

#variation_idObject (readonly)

Returns the value of attribute variation_id.



14
15
16
# File 'lib/kameleoon/data/manager/assigned_variation.rb', line 14

def variation_id
  @variation_id
end

Instance Method Details

#obtain_full_post_text_lineObject



31
32
33
34
35
36
37
38
39
# File 'lib/kameleoon/data/manager/assigned_variation.rb', line 31

def obtain_full_post_text_line
  params = {
    eventType: EVENT_TYPE,
    id: @experiment_id,
    variationId: @variation_id,
    nonce: nonce
  }
  Kameleoon::Network::UriHelper.encode_query(params)
end

#to_sObject



16
17
18
19
# File 'lib/kameleoon/data/manager/assigned_variation.rb', line 16

def to_s
  "AssignedVariation{experiment_id:#{@experiment_id},variation_id:#{@variation_id}," \
    "assignment_time:#{@assignment_time},rule_type:#{@rule_type}}"
end

#valid?(respool_time) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/kameleoon/data/manager/assigned_variation.rb', line 41

def valid?(respool_time)
  respool_time.nil? || (@assignment_time >= respool_time)
end