Class: Statsig::APIRule
- Inherits:
-
Object
- Object
- Statsig::APIRule
- Defined in:
- lib/api_config.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#config_delegate ⇒ Object
Returns the value of attribute config_delegate.
-
#group_name ⇒ Object
Returns the value of attribute group_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#id_type ⇒ Object
Returns the value of attribute id_type.
-
#is_experiment_group ⇒ Object
Returns the value of attribute is_experiment_group.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pass_percentage ⇒ Object
Returns the value of attribute pass_percentage.
-
#return_value ⇒ Object
Returns the value of attribute return_value.
-
#salt ⇒ Object
Returns the value of attribute salt.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, pass_percentage:, return_value:, id:, salt:, conditions:, id_type:, group_name: nil, config_delegate: nil, is_experiment_group: nil) ⇒ APIRule
constructor
A new instance of APIRule.
Constructor Details
#initialize(name:, pass_percentage:, return_value:, id:, salt:, conditions:, id_type:, group_name: nil, config_delegate: nil, is_experiment_group: nil) ⇒ APIRule
Returns a new instance of APIRule.
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/api_config.rb', line 54 def initialize(name:, pass_percentage:, return_value:, id:, salt:, conditions:, id_type:, group_name: nil, config_delegate: nil, is_experiment_group: nil) @name = name @pass_percentage = pass_percentage.to_f @return_value = JSON.parse(JSON.generate(return_value)) @id = id @salt = salt @conditions = conditions @id_type = id_type @group_name = group_name @config_delegate = config_delegate @is_experiment_group = is_experiment_group end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions.
51 52 53 |
# File 'lib/api_config.rb', line 51 def conditions @conditions end |
#config_delegate ⇒ Object
Returns the value of attribute config_delegate.
51 52 53 |
# File 'lib/api_config.rb', line 51 def config_delegate @config_delegate end |
#group_name ⇒ Object
Returns the value of attribute group_name.
51 52 53 |
# File 'lib/api_config.rb', line 51 def group_name @group_name end |
#id ⇒ Object
Returns the value of attribute id.
51 52 53 |
# File 'lib/api_config.rb', line 51 def id @id end |
#id_type ⇒ Object
Returns the value of attribute id_type.
51 52 53 |
# File 'lib/api_config.rb', line 51 def id_type @id_type end |
#is_experiment_group ⇒ Object
Returns the value of attribute is_experiment_group.
51 52 53 |
# File 'lib/api_config.rb', line 51 def is_experiment_group @is_experiment_group end |
#name ⇒ Object
Returns the value of attribute name.
51 52 53 |
# File 'lib/api_config.rb', line 51 def name @name end |
#pass_percentage ⇒ Object
Returns the value of attribute pass_percentage.
51 52 53 |
# File 'lib/api_config.rb', line 51 def pass_percentage @pass_percentage end |
#return_value ⇒ Object
Returns the value of attribute return_value.
51 52 53 |
# File 'lib/api_config.rb', line 51 def return_value @return_value end |
#salt ⇒ Object
Returns the value of attribute salt.
51 52 53 |
# File 'lib/api_config.rb', line 51 def salt @salt end |
Class Method Details
.from_json(json) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/api_config.rb', line 68 def self.from_json(json) new( name: json[:name], pass_percentage: json[:passPercentage], return_value: json[:returnValue] || {}, id: json[:id], salt: json[:salt], conditions: json[:conditions]&.map do |condition| APICondition.from_json(condition) end, id_type: json[:idType], group_name: json[:groupName], config_delegate: json[:configDelegate], is_experiment_group: json[:isExperimentGroup] ) end |