Sha256: d28770113f34f81eeb5ccf826622579cbe4cc76453ac6d0896e47a739200f1b3
Contents?: true
Size: 845 Bytes
Versions: 13
Compression:
Stored size: 845 Bytes
Contents
module Unleash class DefaultOverrideError < RuntimeError end class Strategies attr_accessor :strategies def initialize @strategies = {} end def includes?(name) @strategies.has_key?(name.to_s) || DEFAULT_STRATEGIES.include?(name.to_s) end def add(strategy) raise DefaultOverrideError, "Cannot override a default strategy" if DEFAULT_STRATEGIES.include?(strategy.name) @strategies[strategy.name] = strategy end def custom_strategies @strategies.values end def known_strategies @strategies.keys.map{ |key| { name: key } } end DEFAULT_STRATEGIES = ['applicationHostname', 'default', 'flexibleRollout', 'gradualRolloutRandom', 'gradualRolloutSessionId', 'gradualRolloutUserId', 'remoteAddress', 'userWithId'].freeze end end
Version data entries
13 entries across 13 versions & 1 rubygems