Class: DynamicConfig
- Inherits:
-
Object
- Object
- DynamicConfig
- Extended by:
- T::Sig
- Defined in:
- lib/dynamic_config.rb
Overview
Contains the current experiment/dynamic config values from Statsig
Dynamic Config Documentation: https://docs.statsig.com/dynamic-config
Experiments Documentation: https://docs.statsig.com/experiments-plus
Instance Attribute Summary collapse
-
#evaluation_details ⇒ Object
Returns the value of attribute evaluation_details.
-
#group_name ⇒ Object
Returns the value of attribute group_name.
-
#id_type ⇒ Object
Returns the value of attribute id_type.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rule_id ⇒ Object
Returns the value of attribute rule_id.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#get(index, default_value) ⇒ Object
Get the value for the given key (index), falling back to the default_value if it cannot be found.
-
#get_typed(index, default_value) ⇒ Object
Get the value for the given key (index), falling back to the default_value if it cannot be found or is found to have a different type from the default_value.
-
#initialize(name, value = {}, rule_id = '', group_name = nil, id_type = '', evaluation_details = nil) ⇒ DynamicConfig
constructor
A new instance of DynamicConfig.
Constructor Details
#initialize(name, value = {}, rule_id = '', group_name = nil, id_type = '', evaluation_details = nil) ⇒ DynamicConfig
Returns a new instance of DynamicConfig.
42 43 44 45 46 47 48 49 |
# File 'lib/dynamic_config.rb', line 42 def initialize(name, value = {}, rule_id = '', group_name = nil, id_type = '', evaluation_details = nil) @name = name @value = value @rule_id = rule_id @group_name = group_name @id_type = id_type @evaluation_details = evaluation_details end |
Instance Attribute Details
#evaluation_details ⇒ Object
Returns the value of attribute evaluation_details.
30 31 32 |
# File 'lib/dynamic_config.rb', line 30 def evaluation_details @evaluation_details end |
#group_name ⇒ Object
Returns the value of attribute group_name.
24 25 26 |
# File 'lib/dynamic_config.rb', line 24 def group_name @group_name end |
#id_type ⇒ Object
Returns the value of attribute id_type.
27 28 29 |
# File 'lib/dynamic_config.rb', line 27 def id_type @id_type end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/dynamic_config.rb', line 15 def name @name end |
#rule_id ⇒ Object
Returns the value of attribute rule_id.
21 22 23 |
# File 'lib/dynamic_config.rb', line 21 def rule_id @rule_id end |
#value ⇒ Object
Returns the value of attribute value.
18 19 20 |
# File 'lib/dynamic_config.rb', line 18 def value @value end |
Instance Method Details
#get(index, default_value) ⇒ Object
Get the value for the given key (index), falling back to the default_value if it cannot be found.
57 58 59 60 |
# File 'lib/dynamic_config.rb', line 57 def get(index, default_value) return default_value if @value.nil? || !@value.key?(index) @value[index] end |
#get_typed(index, default_value) ⇒ Object
Get the value for the given key (index), falling back to the default_value if it cannot be found or is found to have a different type from the default_value.
69 70 71 72 73 |
# File 'lib/dynamic_config.rb', line 69 def get_typed(index, default_value) return default_value if @value.nil? || !@value.key?(index) return default_value if @value[index].class != default_value.class and default_value.class != TrueClass and default_value.class != FalseClass @value[index] end |