Class: Flipper::Adapters::Rollout
- Inherits:
-
Object
- Object
- Flipper::Adapters::Rollout
- Includes:
- Adapter
- Defined in:
- lib/flipper/adapters/rollout.rb
Defined Under Namespace
Classes: AdapterMethodNotSupportedError
Instance Method Summary collapse
- #add(_feature) ⇒ Object
- #clear(_feature) ⇒ Object
- #disable(_feature, _gate, _thing) ⇒ Object
- #enable(_feature, _gate, _thing) ⇒ Object
-
#features ⇒ Object
Public: The set of known features.
-
#get(feature) ⇒ Object
Public: Gets the values for all gates for a given feature.
- #import(_source_adapter) ⇒ Object
-
#initialize(rollout) ⇒ Rollout
constructor
A new instance of Rollout.
- #remove(_feature) ⇒ Object
Constructor Details
#initialize(rollout) ⇒ Rollout
Returns a new instance of Rollout.
14 15 16 |
# File 'lib/flipper/adapters/rollout.rb', line 14 def initialize(rollout) @rollout = rollout end |
Instance Method Details
#add(_feature) ⇒ Object
56 57 58 |
# File 'lib/flipper/adapters/rollout.rb', line 56 def add(_feature) raise AdapterMethodNotSupportedError end |
#clear(_feature) ⇒ Object
64 65 66 |
# File 'lib/flipper/adapters/rollout.rb', line 64 def clear(_feature) raise AdapterMethodNotSupportedError end |
#disable(_feature, _gate, _thing) ⇒ Object
72 73 74 |
# File 'lib/flipper/adapters/rollout.rb', line 72 def disable(_feature, _gate, _thing) raise AdapterMethodNotSupportedError end |
#enable(_feature, _gate, _thing) ⇒ Object
68 69 70 |
# File 'lib/flipper/adapters/rollout.rb', line 68 def enable(_feature, _gate, _thing) raise AdapterMethodNotSupportedError end |
#features ⇒ Object
Public: The set of known features.
19 20 21 |
# File 'lib/flipper/adapters/rollout.rb', line 19 def features @rollout.features end |
#get(feature) ⇒ Object
Public: Gets the values for all gates for a given feature.
Returns a Hash of Flipper::Gate#key => value.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/flipper/adapters/rollout.rb', line 26 def get(feature) rollout_feature = @rollout.get(feature.key) return default_config if rollout_feature.nil? boolean = nil groups = Set.new(rollout_feature.groups.map(&:to_s)) actors = Set.new(rollout_feature.users) percentage_of_actors = case rollout_feature.percentage when 100 boolean = true groups = Set.new actors = Set.new nil when 0 nil else rollout_feature.percentage end { boolean: boolean, groups: groups, actors: actors, percentage_of_actors: percentage_of_actors, percentage_of_time: nil, expression: nil, } end |
#import(_source_adapter) ⇒ Object
76 77 78 |
# File 'lib/flipper/adapters/rollout.rb', line 76 def import(_source_adapter) raise AdapterMethodNotSupportedError end |
#remove(_feature) ⇒ Object
60 61 62 |
# File 'lib/flipper/adapters/rollout.rb', line 60 def remove(_feature) raise AdapterMethodNotSupportedError end |