Class: Kameleoon::Configuration::CustomDataInfo
- Inherits:
-
Object
- Object
- Kameleoon::Configuration::CustomDataInfo
- Defined in:
- lib/kameleoon/configuration/custom_data_info.rb
Constant Summary collapse
- SCOPE_VISITOR =
'VISITOR'
Instance Attribute Summary collapse
-
#local_only ⇒ Object
readonly
Returns the value of attribute local_only.
-
#mapping_identifier_index ⇒ Object
readonly
Returns the value of attribute mapping_identifier_index.
-
#visitor_scope ⇒ Object
readonly
Returns the value of attribute visitor_scope.
Class Method Summary collapse
Instance Method Summary collapse
- #get_custom_data_index_by_id(custom_data_id) ⇒ Object
- #get_custom_data_index_by_name(custom_data_name) ⇒ Object
-
#initialize(hashes) ⇒ CustomDataInfo
constructor
A new instance of CustomDataInfo.
- #local_only?(index) ⇒ Boolean
- #mapping_identifier?(index) ⇒ Boolean
- #visitor_scope?(index) ⇒ Boolean
Constructor Details
#initialize(hashes) ⇒ CustomDataInfo
Returns a new instance of CustomDataInfo.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kameleoon/configuration/custom_data_info.rb', line 13 def initialize(hashes) @local_only = Set[] @visitor_scope = Set[] @custom_data_index_by_id = {} @custom_data_index_by_name = {} unless hashes.nil? for hash in hashes index = hash['index'] @local_only.add(index) if hash['localOnly'] @visitor_scope.add(index) if hash['scope'] == SCOPE_VISITOR if index id = hash['id'] name = hash['name'] @custom_data_index_by_id[id] = index if id @custom_data_index_by_name[name] = index if name end if hash['isMappingIdentifier'] unless @mapping_identifier_index.nil? Logging::KameleoonLogger.warning('More than one mapping identifier is set. Undefined behavior ' \ 'may occur on cross-device reconciliation.') end @mapping_identifier_index = index end end end end |
Instance Attribute Details
#local_only ⇒ Object (readonly)
Returns the value of attribute local_only.
9 10 11 |
# File 'lib/kameleoon/configuration/custom_data_info.rb', line 9 def local_only @local_only end |
#mapping_identifier_index ⇒ Object (readonly)
Returns the value of attribute mapping_identifier_index.
9 10 11 |
# File 'lib/kameleoon/configuration/custom_data_info.rb', line 9 def mapping_identifier_index @mapping_identifier_index end |
#visitor_scope ⇒ Object (readonly)
Returns the value of attribute visitor_scope.
9 10 11 |
# File 'lib/kameleoon/configuration/custom_data_info.rb', line 9 def visitor_scope @visitor_scope end |
Class Method Details
.mapping_identifier?(custom_data_info, custom_data) ⇒ Boolean
60 61 62 63 |
# File 'lib/kameleoon/configuration/custom_data_info.rb', line 60 def self.mapping_identifier?(custom_data_info, custom_data) !custom_data_info.nil? && (custom_data.index == custom_data_info.mapping_identifier_index) && \ !(custom_data.values.empty? || custom_data.values[0].empty?) end |
Instance Method Details
#get_custom_data_index_by_id(custom_data_id) ⇒ Object
52 53 54 |
# File 'lib/kameleoon/configuration/custom_data_info.rb', line 52 def get_custom_data_index_by_id(custom_data_id) @custom_data_index_by_id[custom_data_id] end |
#get_custom_data_index_by_name(custom_data_name) ⇒ Object
56 57 58 |
# File 'lib/kameleoon/configuration/custom_data_info.rb', line 56 def get_custom_data_index_by_name(custom_data_name) @custom_data_index_by_name[custom_data_name] end |
#local_only?(index) ⇒ Boolean
40 41 42 |
# File 'lib/kameleoon/configuration/custom_data_info.rb', line 40 def local_only?(index) @local_only.include?(index) end |
#mapping_identifier?(index) ⇒ Boolean
44 45 46 |
# File 'lib/kameleoon/configuration/custom_data_info.rb', line 44 def mapping_identifier?(index) index == @mapping_identifier_index end |
#visitor_scope?(index) ⇒ Boolean
48 49 50 |
# File 'lib/kameleoon/configuration/custom_data_info.rb', line 48 def visitor_scope?(index) @visitor_scope.include?(index) end |