Class: Kameleoon::Targeting::PageUrlCondition Private

Inherits:
StringValueCondition show all
Defined in:
lib/kameleoon/targeting/conditions/page_url_condition.rb

Overview

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.

PageUrlCondition is a condition for checking url of a page

Instance Attribute Summary

Attributes inherited from Condition

#id, #include, #type

Instance Method Summary collapse

Constructor Details

#initialize(json_condition) ⇒ PageUrlCondition

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 PageUrlCondition.



12
13
14
# File 'lib/kameleoon/targeting/conditions/page_url_condition.rb', line 12

def initialize(json_condition)
  super(json_condition, json_condition['url'])
end

Instance Method Details

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



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/kameleoon/targeting/conditions/page_url_condition.rb', line 16

def check(page_view_visits)
  return false unless page_view_visits.is_a?(Kameleoon::DataManager::DataMapStorage)

  latest = nil
  page_view_visits.enumerate do |visit|
    if visit.is_a?(Kameleoon::DataManager::PageViewVisit) \
      && (latest.nil? || visit.last_timestamp > latest.last_timestamp)
      latest = visit
    end
  end
  !latest.nil? && latest.is_a?(Kameleoon::DataManager::PageViewVisit) && check_targeting(latest.page_view.url)
end