Class: Flipper::Gates::Boolean
- Inherits:
-
Flipper::Gate
- Object
- Flipper::Gate
- Flipper::Gates::Boolean
- Defined in:
- lib/flipper/gates/boolean.rb
Constant Summary collapse
- TruthMap =
{ true => true, false => false, 'true' => true, 'false' => false, }
Constants inherited from Flipper::Gate
Flipper::Gate::InstrumentationName
Instance Attribute Summary
Attributes inherited from Flipper::Gate
Instance Method Summary collapse
- #data_type ⇒ Object
- #description(value) ⇒ Object
- #enabled?(value) ⇒ Boolean
-
#key ⇒ Object
Internal: Name converted to value safe for adapter.
-
#name ⇒ Object
Internal: The name of the gate.
-
#open?(thing, value) ⇒ Boolean
Internal: Checks if the gate is open for a thing.
- #protects?(thing) ⇒ Boolean
Methods inherited from Flipper::Gate
#disable, #enable, #initialize, #inspect, #instrument, #wrap
Constructor Details
This class inherits a constructor from Flipper::Gate
Instance Method Details
#data_type ⇒ Object
21 22 23 |
# File 'lib/flipper/gates/boolean.rb', line 21 def data_type :boolean end |
#description(value) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/flipper/gates/boolean.rb', line 25 def description(value) if enabled?(value) 'Enabled' else 'Disabled' end end |
#enabled?(value) ⇒ Boolean
33 34 35 |
# File 'lib/flipper/gates/boolean.rb', line 33 def enabled?(value) !!TruthMap[value] end |
#key ⇒ Object
Internal: Name converted to value safe for adapter.
17 18 19 |
# File 'lib/flipper/gates/boolean.rb', line 17 def key :boolean end |
#name ⇒ Object
Internal: The name of the gate. Used for instrumentation, etc.
12 13 14 |
# File 'lib/flipper/gates/boolean.rb', line 12 def name :boolean end |
#open?(thing, value) ⇒ Boolean
Internal: Checks if the gate is open for a thing.
Returns true if explicitly set to true, false if explicitly set to false or nil if not explicitly set.
41 42 43 44 45 |
# File 'lib/flipper/gates/boolean.rb', line 41 def open?(thing, value) instrument(:open?, thing) { |payload| !!TruthMap[value] } end |