Class: Determinator::Control
- Inherits:
-
Object
- Object
- Determinator::Control
- Defined in:
- lib/determinator/control.rb
Defined Under Namespace
Classes: Indicators
Instance Attribute Summary collapse
-
#retrieval ⇒ Object
readonly
Returns the value of attribute retrieval.
Instance Method Summary collapse
-
#feature_flag_on?(name, id: nil, guid: nil, properties: {}) ⇒ true, false
Determines whether a specific feature is on or off for the given actor.
-
#for_actor(id: nil, guid: nil, default_properties: {}) ⇒ ActorControl
Creates a new determinator instance which assumes the actor id, guid and properties given are always specified.
-
#initialize(retrieval:) ⇒ Control
constructor
A new instance of Control.
- #inspect ⇒ Object
-
#which_variant(name, id: nil, guid: nil, properties: {}) ⇒ false, String
Determines what an actor should see for a specific experiment.
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, properties: {}) ⇒ true, false
Determines whether a specific feature is on or off for the given actor
32 33 34 35 36 |
# File 'lib/determinator/control.rb', line 32 def feature_flag_on?(name, id: nil, guid: nil, properties: {}) determinate_and_notice(name, id: id, guid: guid, properties: properties) do |feature| feature.feature_flag? end end |
#for_actor(id: nil, guid: nil, default_properties: {}) ⇒ ActorControl
Creates a new determinator instance which assumes the actor id, guid and properties given are always specified. This is useful for within a before filter in a webserver, for example, so that the determinator instance made available has the logged-in user’s credentials prefilled.
20 21 22 |
# File 'lib/determinator/control.rb', line 20 def for_actor(id: nil, guid: nil, default_properties: {}) ActorControl.new(self, id: id, guid: guid, default_properties: default_properties) end |
#inspect ⇒ Object
52 53 54 |
# File 'lib/determinator/control.rb', line 52 def inspect '#<Determinator::Control>' end |
#which_variant(name, id: nil, guid: nil, properties: {}) ⇒ false, String
Determines what an actor should see for a specific experiment
46 47 48 49 50 |
# File 'lib/determinator/control.rb', line 46 def which_variant(name, id: nil, guid: nil, properties: {}) determinate_and_notice(name, id: id, guid: guid, properties: properties) do |feature| feature.experiment? end end |