Class: Layer
Overview
Layers Documentation: docs.statsig.com/layers
Instance Attribute Summary collapse
-
#group_name ⇒ Object
Returns the value of attribute group_name.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rule_id ⇒ Object
Returns the value of attribute rule_id.
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, allocated_experiment = nil, exposure_log_func = nil) ⇒ Layer
constructor
A new instance of Layer.
Constructor Details
#initialize(name, value = {}, rule_id = '', group_name = nil, allocated_experiment = nil, exposure_log_func = nil) ⇒ Layer
Returns a new instance of Layer.
33 34 35 36 37 38 39 40 |
# File 'lib/layer.rb', line 33 def initialize(name, value = {}, rule_id = '', group_name = nil, allocated_experiment = nil, exposure_log_func = nil) @name = name @value = value @rule_id = rule_id @group_name = group_name @allocated_experiment = allocated_experiment @exposure_log_func = exposure_log_func end |
Instance Attribute Details
#group_name ⇒ Object
Returns the value of attribute group_name.
21 22 23 |
# File 'lib/layer.rb', line 21 def group_name @group_name end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/layer.rb', line 15 def name @name end |
#rule_id ⇒ Object
Returns the value of attribute rule_id.
18 19 20 |
# File 'lib/layer.rb', line 18 def rule_id @rule_id 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.
48 49 50 51 52 53 54 55 56 |
# File 'lib/layer.rb', line 48 def get(index, default_value) return default_value if @value.nil? || !@value.key?(index) if @exposure_log_func.is_a? Proc @exposure_log_func.call(self, index) end @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.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/layer.rb', line 65 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 if @exposure_log_func.is_a? Proc @exposure_log_func.call(self, index) end @value[index] end |