eppo-server-sdk 0.3.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
-
5
- module EppoClient
6
- # The class for configuring the Eppo client singleton
7
- module VariationType
8
- STRING_TYPE = 'string'
9
- NUMERIC_TYPE = 'numeric'
10
- BOOLEAN_TYPE = 'boolean'
11
- JSON_TYPE = 'json'
12
-
13
- module_function
14
-
15
- # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
16
- def expected_type?(assigned_variation, expected_variation_type)
17
- case expected_variation_type
18
- when STRING_TYPE
19
- assigned_variation.typed_value.is_a?(String)
20
- when NUMERIC_TYPE
21
- assigned_variation.typed_value.is_a?(Numeric)
22
- when BOOLEAN_TYPE
23
- assigned_variation.typed_value.is_a?(TrueClass) ||
24
- assigned_variation.typed_value.is_a?(FalseClass)
25
- when JSON_TYPE
26
- begin
27
- parsed_json = JSON.parse(assigned_variation.value)
28
- JSON.dump(assigned_variation.typed_value)
29
- parsed_json == assigned_variation.typed_value
30
- rescue JSON::JSONError
31
- false
32
- end
33
- else
34
- false
35
- end
36
- end
37
- # rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity
38
- end
39
- end