Togglefy::FeatureQuery
The Togglefy::FeatureQuery class provides methods to query features based on various filters.
Constants
Section titled “Constants”| Name | Description |
|---|---|
FILTERS | Mapping of filter keys to their corresponding query scopes. Available keys: identifier, group/role, environment/env, tenant_id, status |
Methods
Section titled “Methods”features
Section titled “features”Description
Get all features.
Usage
Togglefy.featuresReturn
ActiveRecord::Relationfeature
Section titled “feature”Description
Find feature(s) by identifier.
Parameters
identifier: Symbol || String || Array(String || Symbol)Usage Examples
Togglefy.feature(:feature_name)Togglefy.feature("feature_name")Togglefy.feature([ :feature_name_1, "feature_name_2" ])Return
Togglefy::Feature || ActiveRecord::Relationfor_type
Section titled “for_type”Description
Get feature assignments for an Assignable type.
Parameters
klass: ClassUsage Examples
Togglefy.for_type(User) # This returns all FeatureAssignment with a User assignableReturn
ActiveRecord::Relationfor_group
Section titled “for_group”Description
Get features of a specific group.
Alias
for_roleParameters
group: Symbol || StringUsage Examples
Togglefy.for_group(:admin)Togglefy.for_role(:admin)Return
ActiveRecord::Relationwithout_group
Section titled “without_group”Description
Get features that do not belong to any group.
Alias
without_roleParameters
NoneUsage Examples
Togglefy.without_groupTogglefy.without_roleReturn
ActiveRecord::Relationfor_environment
Section titled “for_environment”Description
Get features of a specific environment.
Alias
for_envParameters
environment: Symbol || StringUsage Examples
Togglefy.for_environment(:production)Togglefy.for_env(:production)Return
ActiveRecord::Relationwithout_environment
Section titled “without_environment”Description
Get features that do not belong to any environment.
Alias
without_envParameters
NoneUsage Examples
Togglefy.without_environmentTogglefy.without_envReturn
ActiveRecord::Relationfor_tenant
Section titled “for_tenant”Description
Get features of a specific tenant.
Parameters
tenant_id: StringUsage Examples
Togglefy.for_tenant("123abc456def789ghi0")Return
ActiveRecord::Relationwithout_tenant
Section titled “without_tenant”Description
Get features that do not belong to any tenant.
Parameters
NoneUsage Examples
Togglefy.without_tenantReturn
ActiveRecord::Relationwith_status
Section titled “with_status”Description
Get features with a specific status.
Parameters
status: Symbol || String || IntegerUsage Examples
Togglefy.with_status(:active)Togglefy.with_status("inactive")Togglefy.with_status(1)Return
ActiveRecord::Relationfor_filters
Section titled “for_filters”Description
Apply multiple filters to the query features.
Parameters
Despite the types informed, you can also pass nil to filter for features that do not have anything set.
filters: { group: Symbol || String || nil, role: Symbol || String || nil, # Acts as a group environment: Symbol || String || nil, env: Symbol || String || nil, # Acts as environment tenant_id: String || nil, status: Symbol || String || Integer || nil, identifier: Symbol || String || Array(String || Symbol) || nil}Usage Examples
Togglefy.for_filters( filters: { group: :admin, environment: :production, status: :active })Return
ActiveRecord::Relation