Class: Flipper::UI::Decorators::Feature
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Flipper::UI::Decorators::Feature
- Includes:
- Comparable
- Defined in:
- lib/flipper/ui/decorators/feature.rb
Constant Summary collapse
- StateSortMap =
{ :on => 1, :conditional => 2, :off => 3, }
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#as_json ⇒ Object
Public: Returns instance as hash that is ready to be json dumped.
- #color_class ⇒ Object
- #pretty_enabled_gate_names ⇒ Object
-
#pretty_name ⇒ Object
Public: Returns name titleized.
Instance Method Details
#<=>(other) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/flipper/ui/decorators/feature.rb', line 53 def <=>(other) if state == other.state key <=> other.key else StateSortMap[state] <=> StateSortMap[other.state] end end |
#as_json ⇒ Object
Public: Returns instance as hash that is ready to be json dumped.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/flipper/ui/decorators/feature.rb', line 20 def as_json gate_values = feature.gate_values { 'id' => name.to_s, 'name' => pretty_name, 'state' => state.to_s, 'gates' => gates.map { |gate| Decorators::Gate.new(gate, gate_values[gate.key]).as_json }, } end |
#color_class ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/flipper/ui/decorators/feature.rb', line 32 def color_class case feature.state when :on "text-open" when :off "text-closed" when :conditional "text-pending" end end |