Class: Determinator::ActorControl

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

Instance Method Summary collapse

Constructor Details

#initialize(controller, id: nil, guid: nil, default_properties: {}) ⇒ ActorControl

Returns a new instance of ActorControl.

See Also:



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_propertiesObject (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

#guidObject (readonly)

Returns the value of attribute guid.



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

def guid
  @guid
end

#idObject (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

Returns:

  • (Boolean)

See Also:



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

#inspectObject



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