Class: Growthbook::Conditions::EvalContext
- Inherits:
-
Object
- Object
- Growthbook::Conditions::EvalContext
- Defined in:
- lib/growthbook/conditions.rb
Overview
Saved groups for one evaluation, and the group ids already being resolved, to stop cycles
Instance Attribute Summary collapse
-
#saved_groups ⇒ Hash
readonly
Saved groups payload, keyed by group id.
-
#visited ⇒ Set<String>
readonly
Ids of the saved groups being resolved.
Instance Method Summary collapse
-
#initialize(saved_groups, visited = Set.new) ⇒ EvalContext
constructor
A new instance of EvalContext.
-
#visiting(id) ⇒ Object
A copy that also holds id, so sibling groups don't see each other's ids.
Constructor Details
#initialize(saved_groups, visited = Set.new) ⇒ EvalContext
Returns a new instance of EvalContext.
25 26 27 28 |
# File 'lib/growthbook/conditions.rb', line 25 def initialize(saved_groups, visited = Set.new) @saved_groups = saved_groups || {} @visited = visited end |
Instance Attribute Details
#saved_groups ⇒ Hash (readonly)
Returns Saved groups payload, keyed by group id.
20 21 22 |
# File 'lib/growthbook/conditions.rb', line 20 def saved_groups @saved_groups end |
#visited ⇒ Set<String> (readonly)
Returns Ids of the saved groups being resolved.
23 24 25 |
# File 'lib/growthbook/conditions.rb', line 23 def visited @visited end |
Instance Method Details
#visiting(id) ⇒ Object
A copy that also holds id, so sibling groups don't see each other's ids
31 32 33 |
# File 'lib/growthbook/conditions.rb', line 31 def visiting(id) EvalContext.new(@saved_groups, @visited.dup.add(id)) end |