Class: Growthbook::Conditions::EvalContext

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.

Returns:

  • (Hash) —

    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.

Returns:

  • (Set<String>) —

    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