Class: Kameleoon::Targeting::PageViewNumberCondition Private

Inherits:
NumberCondition show all
Defined in:
lib/kameleoon/targeting/conditions/page_view_number_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) ⇒ PageViewNumberCondition

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



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

def initialize(json_condition)
  page_count = json_condition['pageCount']
  super(json_condition, page_count)
end

Instance Method Details

#check(page_view_visit_storage) ⇒ 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
# File 'lib/kameleoon/targeting/conditions/page_view_number_condition.rb', line 16

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

  count = 0
  page_view_visit_storage.enumerate do |visit|
    return false unless visit.is_a?(Kameleoon::DataManager::PageViewVisit)
    count += visit.count
  end
  check_targeting(count)
end