Class: Toogle::Feature
- Inherits:
-
Object
- Object
- Toogle::Feature
- Defined in:
- app/models/toogle/feature.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, state:, definition:) ⇒ Feature
constructor
A new instance of Feature.
Constructor Details
#initialize(name:, state:, definition:) ⇒ Feature
Returns a new instance of Feature.
26 27 28 29 30 |
# File 'app/models/toogle/feature.rb', line 26 def initialize(name:, state:, definition:) @name = name @state = state @definition = definition end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
5 6 7 |
# File 'app/models/toogle/feature.rb', line 5 def definition @definition end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'app/models/toogle/feature.rb', line 5 def name @name end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
5 6 7 |
# File 'app/models/toogle/feature.rb', line 5 def state @state end |
Class Method Details
.all ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/toogle/feature.rb', line 7 def self.all definitions_by_name = Definition.all.index_by(&:name) Flipper::Adapters::ActiveRecord.new( feature_class: ::Feature::FlipperFeature, gate_class: ::Feature::FlipperGate ).get_all.map do |feature_name, feature_values| feature_definition = definitions_by_name[feature_name] feature_state = if feature_definition feature_values[:boolean] ? :enabled : :disabled else # This usually happens when switching back from an unmerged feature # branch that introduces a new flag, or when a flag got deleted. :unknown end new(name: feature_name, state: feature_state, definition: feature_definition) end end |