Class: Flagship::Flagset
- Inherits:
-
Object
- Object
- Flagship::Flagset
- Defined in:
- lib/flagship/flagset.rb
Defined Under Namespace
Classes: UndefinedFlagError
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #enabled?(key) ⇒ Boolean
- #features ⇒ Object
-
#initialize(key, features_hash, base = nil) ⇒ Flagset
constructor
A new instance of Flagset.
Constructor Details
#initialize(key, features_hash, base = nil) ⇒ Flagset
Returns a new instance of Flagset.
6 7 8 9 10 11 |
# File 'lib/flagship/flagset.rb', line 6 def initialize(key, features_hash, base = nil) @key = key @features = base ? extend_features(features_hash, base) : features_hash end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
2 3 4 |
# File 'lib/flagship/flagset.rb', line 2 def key @key end |
Instance Method Details
#enabled?(key) ⇒ Boolean
13 14 15 16 17 18 |
# File 'lib/flagship/flagset.rb', line 13 def enabled?(key) raise UndefinedFlagError.new("The flag :#{key} is not defined") unless @features.key? key @features[key].enabled? end |
#features ⇒ Object
20 21 22 |
# File 'lib/flagship/flagset.rb', line 20 def features @features.map { |key, feature| feature } end |