Class: Determinator::Control

Inherits:
Object
  • Object
show all
Defined in:
lib/determinator/control.rb

Defined Under Namespace

Classes: Indicators

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(retrieval:) ⇒ Control

Returns a new instance of Control.



8
9
10
# File 'lib/determinator/control.rb', line 8

def initialize(retrieval:)
  @retrieval = retrieval
end

Instance Attribute Details

#retrieval ⇒ Object (readonly)

Returns the value of attribute retrieval.



6
7
8
# File 'lib/determinator/control.rb', line 6

def retrieval
  @retrieval
end

Instance Method Details

#feature_flag_on?(name, id: nil, guid: nil, constraints: {}) ⇒ true, false

Determines whether a specific feature is on or off for the given actor

Returns:

  • (true, false) —

    Whether the feature is on (true) or off (false) for this actor



20
21
22
23
24
# File 'lib/determinator/control.rb', line 20

def feature_flag_on?(name, id: nil, guid: nil, constraints: {})
  determinate(name, id: id, guid: guid, constraints: constraints) do |feature|
    feature.feature_flag?
  end
end

#for_actor(id: nil, guid: nil, default_constraints: {}) ⇒ ActorControl

Returns A helper object removing the need to know id and guid everywhere.

Returns:

  • (ActorControl) —

    A helper object removing the need to know id and guid everywhere



13
14
15
# File 'lib/determinator/control.rb', line 13

def for_actor(id: nil, guid: nil, default_constraints: {})
  ActorControl.new(self, id: id, guid: guid, default_constraints: default_constraints)
end

#inspect ⇒ Object



35
36
37
# File 'lib/determinator/control.rb', line 35

def inspect
  '#<Determinator::Control>'
end

#which_variant(name, id: nil, guid: nil, constraints: {}) ⇒ false, String

Determines what an actor should see for a specific experiment

Returns:

  • (false, String) —

    Returns false, if the actor is not in this experiment, or otherwise the variant name.



29
30
31
32
33
# File 'lib/determinator/control.rb', line 29

def which_variant(name, id: nil, guid: nil, constraints: {})
  determinate(name, id: id, guid: guid, constraints: constraints) do |feature|
    feature.experiment?
  end
end