Class: Kameleoon::Targeting::ConversionCondition Private

Inherits:
Condition
  • Object
show all
Defined in:
lib/kameleoon/targeting/conditions/conversion_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.

ConversionCondition is a condition for checking targeting of conversions of visitor

Instance Attribute Summary

Attributes inherited from Condition

#id, #include, #type

Instance Method Summary collapse

Constructor Details

#initialize(json_condition) ⇒ ConversionCondition

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



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

def initialize(json_condition)
  super(json_condition)
  @goal_id = json_condition['goalId']
end

Instance Method Details

#check(conversion_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
26
# File 'lib/kameleoon/targeting/conditions/conversion_condition.rb', line 16

def check(conversion_storage)
  return false unless conversion_storage.is_a?(Kameleoon::DataManager::DataArrayStorage)
  return true if @goal_id.nil?

  is_targeted = false
  conversion_storage.enumerate do |conversion|
    is_targeted = conversion.is_a?(Kameleoon::Conversion) && (@goal_id == conversion.goal_id)
    break if is_targeted
  end
  is_targeted
end