Class: Kameleoon::Targeting::VisitorNewReturnCondition Private

Inherits:
Condition
  • Object
show all
Defined in:
lib/kameleoon/targeting/conditions/visitor_new_return_condition.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary

Attributes inherited from Condition

#id, #include, #type

Instance Method Summary collapse

Constructor Details

#initialize(json_condition) ⇒ VisitorNewReturnCondition

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 a new instance of VisitorNewReturnCondition.



14
15
16
17
# File 'lib/kameleoon/targeting/conditions/visitor_new_return_condition.rb', line 14

def initialize(json_condition)
  super(json_condition)
  @visitor_type = json_condition['visitorType']
end

Instance Method Details

#check(data) ⇒ 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.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kameleoon/targeting/conditions/visitor_new_return_condition.rb', line 19

def check(data)
  return false unless VisitorVisits.visitor_visits?(data)

  previous_visit_timestamps = VisitorVisits.get_previous_visit_timestamps(data)
  case @visitor_type
  when VisitorType::NEW
    previous_visit_timestamps.empty?
  when VisitorType::RETURNING
    !previous_visit_timestamps.empty?
  else
    false
  end
end