Class: SplitIoClient::Validators

Inherits:
Object
  • Object
show all
Defined in:
lib/splitclient-rb/validators.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Validators

Returns a new instance of Validators.



6
7
8
# File 'lib/splitclient-rb/validators.rb', line 6

def initialize(config)
  @config = config
end

Instance Method Details

#valid_get_treatment_parameters(method, key, split_name, matching_key, bucketing_key, attributes) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/splitclient-rb/validators.rb', line 10

def valid_get_treatment_parameters(method, key, split_name, matching_key, bucketing_key, attributes)
  valid_key?(method, key) &&
    valid_split_name?(method, split_name) &&
    valid_matching_key?(method, matching_key) &&
    valid_bucketing_key?(method, key, bucketing_key) &&
    valid_attributes?(method, attributes)
end

#valid_get_treatments_parameters(method, split_names) ⇒ Object



18
19
20
# File 'lib/splitclient-rb/validators.rb', line 18

def valid_get_treatments_parameters(method, split_names)
  valid_split_names?(method, split_names)
end

#valid_matcher_arguments(args) ⇒ Object



34
35
36
37
38
39
# File 'lib/splitclient-rb/validators.rb', line 34

def valid_matcher_arguments(args)
  return false if !args.key?(:attributes) && !args.key?(:value)
  return false if args.key?(:value) && args[:value].nil?
  return false if args.key?(:attributes) && args[:attributes].nil?
  true
end

#valid_split_parameters(split_name) ⇒ Object



30
31
32
# File 'lib/splitclient-rb/validators.rb', line 30

def valid_split_parameters(split_name)
  valid_split_name?(:split, split_name)
end

#valid_track_parameters(key, traffic_type_name, event_type, value, properties) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/splitclient-rb/validators.rb', line 22

def valid_track_parameters(key, traffic_type_name, event_type, value, properties)
  valid_track_key?(key) &&
    valid_traffic_type_name?(traffic_type_name) &&
    valid_event_type?(event_type) &&
    valid_value?(value) &&
    valid_properties?(properties)
end