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, }.freeze
Instance Attribute Summary collapse
-
#actor_names ⇒ Object
Internal: Used to preload actor names if actor_names_source is configured for Flipper::UI.
-
#description ⇒ Object
Internal: Used to preload description if descriptions_source is configured for Flipper::UI.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #color_class ⇒ Object
- #gate_state_title ⇒ Object
- #gates_in_words ⇒ Object
- #pretty_enabled_gate_names ⇒ Object
-
#pretty_name ⇒ Object
Public: Returns name titleized.
Instance Attribute Details
#actor_names ⇒ Object
Internal: Used to preload actor names if actor_names_source is configured for Flipper::UI.
20 21 22 |
# File 'lib/flipper/ui/decorators/feature.rb', line 20 def actor_names @actor_names end |
#description ⇒ Object
Internal: Used to preload description if descriptions_source is configured for Flipper::UI.
16 17 18 |
# File 'lib/flipper/ui/decorators/feature.rb', line 16 def description @description end |
Instance Method Details
#<=>(other) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/flipper/ui/decorators/feature.rb', line 83 def <=>(other) if state == other.state key <=> other.key else StateSortMap[state] <=> StateSortMap[other.state] end end |
#color_class ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/flipper/ui/decorators/feature.rb', line 27 def color_class case feature.state when :on 'bg-success' when :off 'bg-danger' when :conditional 'bg-warning' end end |
#gate_state_title ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/flipper/ui/decorators/feature.rb', line 62 def gate_state_title case feature.state when :on "Fully enabled" when :conditional "Conditionally enabled" else "Disabled" end end |
#gates_in_words ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/flipper/ui/decorators/feature.rb', line 38 def gates_in_words return "Fully Enabled" if feature.boolean_value statuses = [] if feature.actors_value.count > 0 statuses << %Q(<span data-toggle="tooltip" data-placement="bottom" title="#{Util.to_sentence(feature.actors_value.to_a)}">) + Util.pluralize(feature.actors_value.count, 'actor', 'actors') + "</span>" end if feature.groups_value.count > 0 statuses << %Q(<span data-toggle="tooltip" data-placement="bottom" title="#{Util.to_sentence(feature.groups_value.to_a)}">) + Util.pluralize(feature.groups_value.count, 'group', 'groups') + "</span>" end if feature.percentage_of_actors_value > 0 statuses << "#{feature.percentage_of_actors_value}% of actors" end if feature.percentage_of_time_value > 0 statuses << "#{feature.percentage_of_time_value}% of time" end Util.to_sentence(statuses) end |