Class: Ant::Configuration::FeatureFlag
- Inherits:
-
Object
- Object
- Ant::Configuration::FeatureFlag
show all
- Extended by:
- DRY::ResourceInjector
- Defined in:
- lib/ant/configs/feature_flag.rb,
lib/ant/configs/feature_flag/ab_test.rb,
lib/ant/configs/feature_flag/canarying.rb,
lib/ant/configs/feature_flag/feature_flag.rb
Defined Under Namespace
Classes: ABTest, Base, Canarying
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of FeatureFlag.
12
13
14
15
16
17
|
# File 'lib/ant/configs/feature_flag.rb', line 12
def initialize(confs)
@flags = {}
confs.each do |name, conf|
@flags[name] = self.class.from_config(conf)
end
end
|
Class Method Details
.from_config(conf) ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/ant/configs/feature_flag.rb', line 26
def self.from_config(conf)
case conf
when String, TrueClass, FalseClass
Base.new(conf)
when Hash
klass = resource(:custom_provider, conf['provider'])
klass.new(conf)
end
end
|
.register_provider(name, klass) ⇒ Object
36
37
38
|
# File 'lib/ant/configs/feature_flag.rb', line 36
def self.register_provider(name, klass)
register(:custom_provider, name, klass)
end
|
Instance Method Details
#[](key) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/ant/configs/feature_flag.rb', line 19
def [](key)
feature_flag = @flags[key]
raise KeyError, "#{key} is not configured as flag" unless feature_flag
feature_flag.active?
end
|