Class: FeatureFlagger::Control

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(storage) ⇒ Control

Returns a new instance of Control.


5
6
7
# File 'lib/feature_flagger/control.rb', line 5

def initialize(storage)
  @storage = storage
end

Instance Attribute Details

#storageObject (readonly)

Returns the value of attribute storage


3
4
5
# File 'lib/feature_flagger/control.rb', line 3

def storage
  @storage
end

Instance Method Details

#release!(feature_key, resource_id, resource_name = nil) ⇒ Object


14
15
16
17
# File 'lib/feature_flagger/control.rb', line 14

def release!(feature_key, resource_id, resource_name = nil)
  feature_key = rsolv_key(feature_key, resource_name)
  @storage.add(feature_key, resource_id)
end

#resource_ids(feature_key, resource_name = nil) ⇒ Object


24
25
26
27
# File 'lib/feature_flagger/control.rb', line 24

def resource_ids(feature_key, resource_name = nil)
  feature_key = rsolv_key(feature_key, resource_name)
  @storage.all_values(feature_key)
end

#rollout?(feature_key, resource_id, resource_name = nil) ⇒ Boolean

Returns:

  • (Boolean)

9
10
11
12
# File 'lib/feature_flagger/control.rb', line 9

def rollout?(feature_key, resource_id, resource_name = nil)
  feature_key = rsolv_key(feature_key, resource_name)
  @storage.has_value?(feature_key, resource_id)
end

#unrelease!(feature_key, resource_id, resource_name = nil) ⇒ Object


19
20
21
22
# File 'lib/feature_flagger/control.rb', line 19

def unrelease!(feature_key, resource_id, resource_name = nil)
  feature_key = rsolv_key(feature_key, resource_name)
  @storage.remove(feature_key, resource_id)
end