Class: Flagship::Feature
- Inherits:
-
Object
- Object
- Flagship::Feature
- Defined in:
- lib/flagship/feature.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #disabled? ⇒ Boolean
- #enabled? ⇒ Boolean
- #extend_feature(feature) ⇒ Object
-
#initialize(key, enabled, context, tags = {}) ⇒ Feature
constructor
A new instance of Feature.
Constructor Details
#initialize(key, enabled, context, tags = {}) ⇒ Feature
4 5 6 7 8 9 |
# File 'lib/flagship/feature.rb', line 4 def initialize(key, enabled, context, = {}) @key = key @enabled = enabled @context = context = end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
2 3 4 |
# File 'lib/flagship/feature.rb', line 2 def key @key end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
2 3 4 |
# File 'lib/flagship/feature.rb', line 2 def end |
Instance Method Details
#disabled? ⇒ Boolean
30 31 32 |
# File 'lib/flagship/feature.rb', line 30 def disabled? !enabled? end |
#enabled? ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/flagship/feature.rb', line 11 def enabled? env = ENV['FLAGSHIP_' + key.to_s.upcase] if env case env.downcase when '1', 'true' return true when '0', 'false', '' return false end end if @enabled.respond_to?(:call) !!@enabled.call(@context) else !!@enabled end end |
#extend_feature(feature) ⇒ Object
34 35 36 |
# File 'lib/flagship/feature.rb', line 34 def extend_feature(feature) self.class.new(@key, @enabled, @context, feature..merge()) end |