Class: Flagship::Flagset
- Inherits:
-
Object
- Object
- Flagship::Flagset
- Defined in:
- lib/flagship/flagset.rb
Defined Under Namespace
Classes: UndefinedFlagError
Instance Attribute Summary collapse
-
#helper_methods ⇒ Object
readonly
Returns the value of attribute helper_methods.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #disabled?(key) ⇒ Boolean
- #enabled?(key) ⇒ Boolean
- #features ⇒ Object
-
#initialize(key, features_hash, base = nil, helper_methods = []) ⇒ Flagset
constructor
A new instance of Flagset.
Constructor Details
#initialize(key, features_hash, base = nil, helper_methods = []) ⇒ Flagset
Returns a new instance of Flagset.
6 7 8 9 10 11 12 |
# 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 |
Instance Attribute Details
#helper_methods ⇒ Object (readonly)
Returns the value of attribute helper_methods.
2 3 4 |
# File 'lib/flagship/flagset.rb', line 2 def helper_methods @helper_methods end |
#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
#disabled?(key) ⇒ Boolean
21 22 23 |
# File 'lib/flagship/flagset.rb', line 21 def disabled?(key) !enabled?(key) end |
#enabled?(key) ⇒ Boolean
14 15 16 17 18 19 |
# 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 |