Class: Determinator::ActorControl
- Inherits:
-
Object
- Object
- Determinator::ActorControl
- Defined in:
- lib/determinator/actor_control.rb
Overview
A decorator to provide syntactic sugar for Determinator::Control. Useful for contexts where the actor remains constant (eg. inside the request cycle in a webapp)
Instance Attribute Summary collapse
-
#default_properties ⇒ Object
readonly
Returns the value of attribute default_properties.
-
#guid ⇒ Object
readonly
Returns the value of attribute guid.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #feature_flag_on?(name, properties: {}) ⇒ Boolean
-
#initialize(controller, id: nil, guid: nil, default_properties: {}) ⇒ ActorControl
constructor
A new instance of ActorControl.
- #inspect ⇒ Object
- #which_variant(name, properties: {}) ⇒ Object
Constructor Details
#initialize(controller, id: nil, guid: nil, default_properties: {}) ⇒ ActorControl
Returns a new instance of ActorControl.
9 10 11 12 13 14 |
# File 'lib/determinator/actor_control.rb', line 9 def initialize(controller, id: nil, guid: nil, default_properties: {}) @id = id @guid = guid @default_properties = default_properties @controller = controller end |
Instance Attribute Details
#default_properties ⇒ Object (readonly)
Returns the value of attribute default_properties.
6 7 8 |
# File 'lib/determinator/actor_control.rb', line 6 def default_properties @default_properties end |
#guid ⇒ Object (readonly)
Returns the value of attribute guid.
6 7 8 |
# File 'lib/determinator/actor_control.rb', line 6 def guid @guid end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/determinator/actor_control.rb', line 6 def id @id end |
Instance Method Details
#feature_flag_on?(name, properties: {}) ⇒ Boolean
27 28 29 30 31 32 33 34 |
# File 'lib/determinator/actor_control.rb', line 27 def feature_flag_on?(name, properties: {}) controller.feature_flag_on?( name, id: id, guid: guid, properties: default_properties.merge(properties) ) end |
#inspect ⇒ Object
36 37 38 |
# File 'lib/determinator/actor_control.rb', line 36 def inspect "#<Determinator::ActorControl id=#{id.inspect} guid=#{guid.inspect}>" end |
#which_variant(name, properties: {}) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/determinator/actor_control.rb', line 17 def which_variant(name, properties: {}) controller.which_variant( name, id: id, guid: guid, properties: default_properties.merge(properties) ) end |