class Flagship::Flagset
Attributes
helper_methods[R]
key[R]
Public Class Methods
new(key, features_hash, base = nil, helper_methods = [])
click to toggle source
# File lib/flagship/flagset.rb, line 6 def initialize(key, features_hash, base = nil, helper_methods = []) @key = key @features = base ? extend_features(features_hash, base) : features_hash @helper_methods = helper_methods end
Public Instance Methods
disabled?(key)
click to toggle source
# File lib/flagship/flagset.rb, line 21 def disabled?(key) !enabled?(key) end
enabled?(key)
click to toggle source
# File lib/flagship/flagset.rb, line 14 def enabled?(key) raise UndefinedFlagError.new("The flag :#{key} is not defined") unless @features.key? key @features[key].enabled? end
features()
click to toggle source
# File lib/flagship/flagset.rb, line 25 def features Flagship::Features.new @features.map { |key, feature| feature } end
Private Instance Methods
extend_features(features_hash, base)
click to toggle source
# File lib/flagship/flagset.rb, line 31 def extend_features(features_hash, base) base.features.map { |f| [f.key, f] }.to_h.merge(features_hash) { |key, base_f, new_f| new_f.extend_feature(base_f) } end