Class: Flagsmith::Engine::Identities::FeaturesList
- Inherits:
-
Object
- Object
- Flagsmith::Engine::Identities::FeaturesList
- Includes:
- Enumerable
- Defined in:
- lib/flagsmith/engine/identities/models.rb
Overview
IdentityFeaturesList
Class Method Summary collapse
Instance Method Summary collapse
- #<<(item) ⇒ Object (also: #push)
- #each(&block) ⇒ Object
-
#initialize(list = []) ⇒ FeaturesList
constructor
A new instance of FeaturesList.
Constructor Details
#initialize(list = []) ⇒ FeaturesList
Returns a new instance of FeaturesList.
83 84 85 86 |
# File 'lib/flagsmith/engine/identities/models.rb', line 83 def initialize(list = []) @list = [] list.each { |item| @list << item } end |
Class Method Details
.build(identity_features) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/flagsmith/engine/identities/models.rb', line 104 def build(identity_features) return new unless identity_features&.any? new( identity_features.map { |f| Flagsmith::Engine::FeatureState.build(f) } ) end |
Instance Method Details
#<<(item) ⇒ Object Also known as: push
88 89 90 91 92 93 94 95 |
# File 'lib/flagsmith/engine/identities/models.rb', line 88 def <<(item) @list.each do |v| next unless v.django_id == item.django_id raise NotUniqueFeatureState, "Feature state for this feature already exists, django_id: #{django_id}" end @list << item end |
#each(&block) ⇒ Object
99 100 101 |
# File 'lib/flagsmith/engine/identities/models.rb', line 99 def each(&block) @list.each { |item| block&.call(item) || item } end |