Class: Togglefy::Feature
- Inherits:
-
Object
- Object
- Togglefy::Feature
- Defined in:
- app/models/togglefy/feature.rb
Overview
Represents a feature in the Togglefy system. A feature can have various attributes such as name, identifier, status, and associations with assignables.
Instance Attribute Summary collapse
-
#feature_assignments ⇒ ActiveRecord::Relation
The feature assignments associated with this feature.
Instance Method Summary collapse
-
#active ⇒ ActiveRecord::Relation
Finds features with an active status.
-
#assignables ⇒ ActiveRecord::Relation
This method retrieves all assignables linked to the feature through feature assignments.
-
#assignables_for_type(klass) ⇒ ActiveRecord::Relation
This method retrieves assignables of a specific class linked to the feature through feature assignments.
-
#for_environment ⇒ ActiveRecord::Relation
Finds features by their environment.
-
#for_group ⇒ ActiveRecord::Relation
Finds features by their group.
-
#for_tenant ⇒ ActiveRecord::Relation
Finds features by their tenant ID.
-
#identifier ⇒ ActiveRecord::Relation
Scopes Finds features by their identifier.
-
#inactive ⇒ ActiveRecord::Relation
Finds features with an inactive status.
-
#with_status ⇒ ActiveRecord::Relation
Finds features by their status.
-
#without_environment ⇒ ActiveRecord::Relation
Finds features without an environment.
-
#without_group ⇒ ActiveRecord::Relation
Finds features without a group.
-
#without_tenant ⇒ ActiveRecord::Relation
Finds features without a tenant.
Instance Attribute Details
#feature_assignments ⇒ ActiveRecord::Relation
Returns The feature assignments associated with this feature.
21 |
# File 'app/models/togglefy/feature.rb', line 21 has_many :feature_assignments, dependent: :destroy |
Instance Method Details
#active ⇒ ActiveRecord::Relation
Finds features with an active status.
66 |
# File 'app/models/togglefy/feature.rb', line 66 scope :active, -> { where(status: :active) } |
#assignables ⇒ ActiveRecord::Relation
This method includes all assignables, regardless of their class.
This method retrieves all assignables linked to the feature through feature assignments.
89 90 91 |
# File 'app/models/togglefy/feature.rb', line 89 def assignables feature_assignments.includes(:assignable).map(&:assignable) end |
#assignables_for_type(klass) ⇒ ActiveRecord::Relation
This method retrieves assignables of a specific class linked to the feature through feature assignments.
101 102 103 |
# File 'app/models/togglefy/feature.rb', line 101 def assignables_for_type(klass) feature_assignments.includes(:assignable).where(assignable_type: klass.to_s).map(&:assignable) end |
#for_environment ⇒ ActiveRecord::Relation
Finds features by their environment.
45 |
# File 'app/models/togglefy/feature.rb', line 45 scope :for_environment, ->(environment) { where(environment: environment) } |
#for_group ⇒ ActiveRecord::Relation
Finds features by their group.
36 |
# File 'app/models/togglefy/feature.rb', line 36 scope :for_group, ->(group) { where(group: group) } |
#for_tenant ⇒ ActiveRecord::Relation
Finds features by their tenant ID.
54 |
# File 'app/models/togglefy/feature.rb', line 54 scope :for_tenant, ->(tenant_id) { where(tenant_id: tenant_id) } |
#identifier ⇒ ActiveRecord::Relation
Scopes Finds features by their identifier.
31 |
# File 'app/models/togglefy/feature.rb', line 31 scope :identifier, ->(identifier) { where(identifier: identifier) } |
#inactive ⇒ ActiveRecord::Relation
Finds features with an inactive status.
62 |
# File 'app/models/togglefy/feature.rb', line 62 scope :inactive, -> { where(status: :inactive) } |
#with_status ⇒ ActiveRecord::Relation
Finds features by their status. (:inactive || “inactive” || 0) or (:active || “active” || 1).
72 |
# File 'app/models/togglefy/feature.rb', line 72 scope :with_status, ->(status) { where(status: status) } |
#without_environment ⇒ ActiveRecord::Relation
Finds features without an environment.
49 |
# File 'app/models/togglefy/feature.rb', line 49 scope :without_environment, -> { where(environment: nil) } |
#without_group ⇒ ActiveRecord::Relation
Finds features without a group.
40 |
# File 'app/models/togglefy/feature.rb', line 40 scope :without_group, -> { where(group: nil) } |
#without_tenant ⇒ ActiveRecord::Relation
Finds features without a tenant.
58 |
# File 'app/models/togglefy/feature.rb', line 58 scope :without_tenant, -> { where(tenant_id: nil) } |