Class: ContextConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/context_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContextConfig

Returns a new instance of ContextConfig.



11
12
13
14
15
16
# File 'lib/context_config.rb', line 11

def initialize
  @units = {}
  @attributes = {}
  @overrides = {}
  @custom_assignments = {}
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



4
5
6
# File 'lib/context_config.rb', line 4

def attributes
  @attributes
end

#custom_assignmentsObject

Returns the value of attribute custom_assignments.



4
5
6
# File 'lib/context_config.rb', line 4

def custom_assignments
  @custom_assignments
end

#event_loggerObject

Returns the value of attribute event_logger.



4
5
6
# File 'lib/context_config.rb', line 4

def event_logger
  @event_logger
end

#overridesObject

Returns the value of attribute overrides.



4
5
6
# File 'lib/context_config.rb', line 4

def overrides
  @overrides
end

#publish_delayObject

Returns the value of attribute publish_delay.



4
5
6
# File 'lib/context_config.rb', line 4

def publish_delay
  @publish_delay
end

#refresh_intervalObject

Returns the value of attribute refresh_interval.



4
5
6
# File 'lib/context_config.rb', line 4

def refresh_interval
  @refresh_interval
end

#unitsObject

Returns the value of attribute units.



4
5
6
# File 'lib/context_config.rb', line 4

def units
  @units
end

Class Method Details

.createObject



7
8
9
# File 'lib/context_config.rb', line 7

def self.create
  ContextConfig.new
end

Instance Method Details

#attribute(name) ⇒ Object



40
41
42
# File 'lib/context_config.rb', line 40

def attribute(name)
  @attributes[name.to_sym]
end

#custom_assignment(experiment_name) ⇒ Object



67
68
69
# File 'lib/context_config.rb', line 67

def custom_assignment(experiment_name)
  @custom_assignments[experiment_name.to_sym]
end

#override(experiment_name) ⇒ Object



53
54
55
# File 'lib/context_config.rb', line 53

def override(experiment_name)
  @overrides[experiment_name.to_sym]
end

#set_attribute(name, value) ⇒ Object



35
36
37
38
# File 'lib/context_config.rb', line 35

def set_attribute(name, value)
  @attributes[name.to_sym] = value
  self
end

#set_attributes(attributes) ⇒ Object



31
32
33
# File 'lib/context_config.rb', line 31

def set_attributes(attributes)
  @attributes ||= attributes.transform_keys(&:to_sym)
end

#set_custom_assignment(experiment_name, variant) ⇒ Object



57
58
59
60
# File 'lib/context_config.rb', line 57

def set_custom_assignment(experiment_name, variant)
  @custom_assignments[experiment_name.to_sym] = variant
  self
end

#set_custom_assignments(customAssignments) ⇒ Object



62
63
64
65
# File 'lib/context_config.rb', line 62

def set_custom_assignments(customAssignments)
  @custom_assignments.merge!(customAssignments.transform_keys(&:to_sym))
  self
end

#set_event_logger(event_logger) ⇒ Object



72
73
74
75
# File 'lib/context_config.rb', line 72

def set_event_logger(event_logger)
  @event_logger = event_logger
  self
end

#set_override(experiment_name, variant) ⇒ Object



48
49
50
51
# File 'lib/context_config.rb', line 48

def set_override(experiment_name, variant)
  @overrides[experiment_name.to_sym] = variant
  self
end

#set_overrides(overrides) ⇒ Object



44
45
46
# File 'lib/context_config.rb', line 44

def set_overrides(overrides)
  @overrides.merge!(overrides.transform_keys(&:to_sym))
end

#set_unit(unit_type, uid) ⇒ Object



18
19
20
21
# File 'lib/context_config.rb', line 18

def set_unit(unit_type, uid)
  @units[unit_type.to_sym] = uid
  self
end

#set_units(units) ⇒ Object



23
24
25
# File 'lib/context_config.rb', line 23

def set_units(units)
  units.map { |k, v| set_unit(k, v) }
end

#unit(unit_type) ⇒ Object



27
28
29
# File 'lib/context_config.rb', line 27

def unit(unit_type)
  @units[unit_type.to_sym]
end