Class: ContextConfig
- Inherits:
-
Object
- Object
- ContextConfig
- Defined in:
- lib/context_config.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#custom_assignments ⇒ Object
Returns the value of attribute custom_assignments.
-
#event_logger ⇒ Object
Returns the value of attribute event_logger.
-
#overrides ⇒ Object
Returns the value of attribute overrides.
-
#publish_delay ⇒ Object
Returns the value of attribute publish_delay.
-
#refresh_interval ⇒ Object
Returns the value of attribute refresh_interval.
-
#units ⇒ Object
Returns the value of attribute units.
Class Method Summary collapse
Instance Method Summary collapse
- #attribute(name) ⇒ Object
- #custom_assignment(experiment_name) ⇒ Object
-
#initialize ⇒ ContextConfig
constructor
A new instance of ContextConfig.
- #override(experiment_name) ⇒ Object
- #set_attribute(name, value) ⇒ Object
- #set_attributes(attributes) ⇒ Object
- #set_custom_assignment(experiment_name, variant) ⇒ Object
- #set_custom_assignments(customAssignments) ⇒ Object
- #set_event_logger(event_logger) ⇒ Object
- #set_override(experiment_name, variant) ⇒ Object
- #set_overrides(overrides) ⇒ Object
- #set_unit(unit_type, uid) ⇒ Object
- #set_units(units) ⇒ Object
- #unit(unit_type) ⇒ Object
Constructor Details
#initialize ⇒ ContextConfig
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
#attributes ⇒ Object
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/context_config.rb', line 4 def attributes @attributes end |
#custom_assignments ⇒ Object
Returns the value of attribute custom_assignments.
4 5 6 |
# File 'lib/context_config.rb', line 4 def custom_assignments @custom_assignments end |
#event_logger ⇒ Object
Returns the value of attribute event_logger.
4 5 6 |
# File 'lib/context_config.rb', line 4 def event_logger @event_logger end |
#overrides ⇒ Object
Returns the value of attribute overrides.
4 5 6 |
# File 'lib/context_config.rb', line 4 def overrides @overrides end |
#publish_delay ⇒ Object
Returns the value of attribute publish_delay.
4 5 6 |
# File 'lib/context_config.rb', line 4 def publish_delay @publish_delay end |
#refresh_interval ⇒ Object
Returns the value of attribute refresh_interval.
4 5 6 |
# File 'lib/context_config.rb', line 4 def refresh_interval @refresh_interval end |
#units ⇒ Object
Returns the value of attribute units.
4 5 6 |
# File 'lib/context_config.rb', line 4 def units @units end |
Class Method Details
.create ⇒ Object
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 |