class Flipper::Adapters::Rollout

Attributes

name[R]

Public: The name of the adapter.

Public Class Methods

new(rollout) click to toggle source
# File lib/flipper/adapters/rollout.rb, line 17
def initialize(rollout)
  @rollout = rollout
  @name = :rollout
end

Public Instance Methods

add(_feature) click to toggle source
# File lib/flipper/adapters/rollout.rb, line 59
def add(_feature)
  raise AdapterMethodNotSupportedError
end
clear(_feature) click to toggle source
# File lib/flipper/adapters/rollout.rb, line 67
def clear(_feature)
  raise AdapterMethodNotSupportedError
end
disable(_feature, _gate, _thing) click to toggle source
# File lib/flipper/adapters/rollout.rb, line 75
def disable(_feature, _gate, _thing)
  raise AdapterMethodNotSupportedError
end
enable(_feature, _gate, _thing) click to toggle source
# File lib/flipper/adapters/rollout.rb, line 71
def enable(_feature, _gate, _thing)
  raise AdapterMethodNotSupportedError
end
features() click to toggle source

Public: The set of known features.

# File lib/flipper/adapters/rollout.rb, line 23
def features
  @rollout.features
end
get(feature) click to toggle source

Public: Gets the values for all gates for a given feature.

Returns a Hash of Flipper::Gate#key => value.

# File lib/flipper/adapters/rollout.rb, line 30
def get(feature)
  rollout_feature = @rollout.get(feature.key)
  return default_config if rollout_feature.nil?

  boolean = nil
  groups = Set.new(rollout_feature.groups)
  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,
  }
end
import(_source_adapter) click to toggle source
# File lib/flipper/adapters/rollout.rb, line 79
def import(_source_adapter)
  raise AdapterMethodNotSupportedError
end
remove(_feature) click to toggle source
# File lib/flipper/adapters/rollout.rb, line 63
def remove(_feature)
  raise AdapterMethodNotSupportedError
end