### Starting Flippant Source: https://context7.com/sorentwo/flippant/llms.txt How to integrate Flippant into your application's supervision tree and perform initial setup for the PostgreSQL adapter. ```APIDOC ## Starting Flippant Start Flippant as part of your application supervision tree. ```elixir # In your application.ex defmodule MyApp.Application do use Application def start(_type, _args) do children = [ {Flippant, []}, # ... other children ] opts = [strategy: :one_for_one, name: MyApp.Supervisor] Supervisor.start_link(children, opts) end end # For Postgres adapter, run setup to create the table Flippant.setup() ``` ``` -------------------------------- ### Start Flippant in Application Supervision Tree Source: https://context7.com/sorentwo/flippant/llms.txt Add Flippant to the application supervision tree and run setup for persistent storage adapters like Postgres. ```elixir # In your application.ex defmodule MyApp.Application do use Application def start(_type, _args) do children = [ {Flippant, []}, # ... other children ] opts = [strategy: :one_for_one, name: MyApp.Supervisor] Supervisor.start_link(children, opts) end end # For Postgres adapter, run setup to create the table Flippant.setup() ``` -------------------------------- ### Installation and Configuration Source: https://context7.com/sorentwo/flippant/llms.txt Instructions on how to add Flippant to your project dependencies and configure it with different storage adapters (Redis, PostgreSQL, Memory). ```APIDOC ## Installation and Configuration Add Flippant to your dependencies and configure an adapter for persistent storage. ```elixir # mix.exs def deps do [ {:flippant, "~> 2.0"}, {:redix, "~> 1.0"} # or {:postgrex, "~> 0.14"} for Postgres ] end # config/config.exs - Redis adapter config :flippant, adapter: Flippant.Adapter.Redis, redis_opts: [url: System.get_env("REDIS_URL"), name: :flippant], set_key: "flippant-features" # config/config.exs - Postgres adapter config :flippant, adapter: Flippant.Adapter.Postgres, postgres_opts: [ database: "my_app_production", username: "postgres", password: "secret", hostname: "localhost" ], table: "flippant_features" # config/test.exs - Memory adapter for testing config :flippant, adapter: Flippant.Adapter.Memory ``` ``` -------------------------------- ### Configure Flippant Adapter Source: https://github.com/sorentwo/flippant/blob/main/README.md Set the adapter and its options in your config.exs file. This example configures the Redis adapter. ```elixir config :flippant, adapter: Flippant.Adapter.Redis, redis_opts: [url: System.get_env("REDIS_URL"), name: :flippant], set_key: "flippant-features" ``` -------------------------------- ### Application Startup with Groups Source: https://context7.com/sorentwo/flippant/llms.txt Define groups at application start using a temporary worker module. ```APIDOC ## Application Startup with Groups ### Description Define groups at application start using a temporary worker module. ### Method N/A (Module Definition and Application Configuration) ### Endpoint N/A ### Parameters None ### Request Example ```elixir # lib/my_app/feature_groups.ex defmodule MyApp.FeatureGroups do def start_link do Flippant.register("everybody", fn _actor, _values -> true end) Flippant.register("nobody", fn _actor, _values -> false end) Flippant.register("staff", fn %{staff?: true}, _values -> true _, _ -> false end) Flippant.register("beta_testers", fn %{id: id}, ids -> id in ids _, _ -> false end) Flippant.register("percentage", fn _actor, [] -> false %{id: id}, samples -> rem(id, 10) in samples _, _ -> false end) :ignore end end # lib/my_app/application.ex defmodule MyApp.Application do use Application def start(_type, _args) do children = [ {Flippant, []}, {MyApp.FeatureGroups, [], restart: :temporary} ] opts = [strategy: :one_for_one, name: MyApp.Supervisor] Supervisor.start_link(children, opts) end end ``` ### Response N/A ### Notes - This demonstrates how to define custom feature groups and integrate them into the application's supervision tree. ``` -------------------------------- ### Flippant.setup/0 Source: https://context7.com/sorentwo/flippant/llms.txt Prepares the adapter for usage. For Postgres, this creates the required database table. ```APIDOC ## Flippant.setup/0 ### Description Prepares the adapter for usage. For Postgres, this creates the required database table. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters None ### Request Example ```elixir Flippant.setup() ``` ### Response #### Success Response (200) - `:ok` (atom) - Indicates successful setup. #### Response Example ```elixir :ok ``` ### Notes - For Postgres adapter, this executes `CREATE TABLE IF NOT EXISTS flippant_features (...)`. - For Memory and Redis adapters, this is a no-op. ``` -------------------------------- ### Initialize Flippant Adapter Source: https://context7.com/sorentwo/flippant/llms.txt Prepares the adapter for use. For Postgres, this ensures the required database table exists. ```elixir # For Postgres adapter - creates the flippant_features table Flippant.setup() #=> :ok # Equivalent SQL that gets executed: # CREATE TABLE IF NOT EXISTS flippant_features ( # name varchar(140) NOT NULL CHECK (name <> ''), # rules jsonb NOT NULL DEFAULT '{}'::jsonb, # CONSTRAINT unique_name UNIQUE(name) # ) # For Memory and Redis adapters, this is a no-op Flippant.setup() #=> :ok ``` -------------------------------- ### Manage Feature Flags and Backups Source: https://context7.com/sorentwo/flippant/llms.txt Demonstrates enabling features, dumping state to files, and clearing/loading configurations. ```elixir Flippant.enable("search", "staff") Flippant.enable("search", "beta_testers", [1001, 1002]) Flippant.enable("delete", "staff") Flippant.enable("export", "premium") # Dump to file Flippant.dump("features_backup.json") #=> :ok # Create dated backup date = Date.utc_today() |> Date.to_string() Flippant.dump("#{date}_features.dump") #=> :ok # Clear and restore Flippant.clear() Flippant.features() #=> [] Flippant.load("features_backup.json") #=> :ok Flippant.features() #=> ["delete", "export", "search"] ``` -------------------------------- ### Configure Flippant Dependencies and Adapters Source: https://context7.com/sorentwo/flippant/llms.txt Define dependencies in mix.exs and configure the desired storage adapter in config files. ```elixir # mix.exs def deps do [ {:flippant, "~> 2.0"}, {:redix, "~> 1.0"} # or {:postgrex, "~> 0.14"} for Postgres ] end # config/config.exs - Redis adapter config :flippant, adapter: Flippant.Adapter.Redis, redis_opts: [url: System.get_env("REDIS_URL"), name: :flippant], set_key: "flippant-features" # config/config.exs - Postgres adapter config :flippant, adapter: Flippant.Adapter.Postgres, postgres_opts: [ database: "my_app_production", username: "postgres", password: "secret", hostname: "localhost" ], table: "flippant_features" # config/test.exs - Memory adapter for testing config :flippant, adapter: Flippant.Adapter.Memory ``` -------------------------------- ### Add Adapter Dependency (e.g., Redix) Source: https://github.com/sorentwo/flippant/blob/main/README.md Include an adapter like Redix for Redis or Postgrex for PostgreSQL in your dependencies. ```elixir def deps do [{:redix, "~> 1.0"}] end ``` -------------------------------- ### Testing with Memory Adapter Source: https://context7.com/sorentwo/flippant/llms.txt Use the Memory adapter for fast, isolated testing without external dependencies. ```APIDOC ## Testing with Memory Adapter ### Description Use the Memory adapter for fast, isolated testing without external dependencies. ### Method N/A (Configuration and Test Cases) ### Endpoint N/A ### Parameters None ### Request Example ```elixir # config/test.exs config :flippant, adapter: Flippant.Adapter.Memory # test/features_test.exs defmodule FeaturesTest do use ExUnit.Case setup do Flippant.clear() Flippant.update_config(:rules, MyApp.TestRules) on_exit(fn -> Flippant.update_config(:rules, Flippant.Rules.Default) end) end test "staff users can access admin features" do Flippant.enable("admin_panel", "staff") staff = %{id: 1, staff?: true} regular = %{id: 2, staff?: false} assert Flippant.enabled?("admin_panel", staff) refute Flippant.enabled?("admin_panel", regular) end test "beta features can be enabled for specific users" do Flippant.enable("new_ui", "beta_testers", [100, 101, 102]) beta_user = %{id: 101, staff?: false} other_user = %{id: 999, staff?: false} assert Flippant.enabled?("new_ui", beta_user) refute Flippant.enabled?("new_ui", other_user) end end ``` ### Response N/A ### Notes - Configures Flippant to use the in-memory adapter for tests. - `Flippant.clear/0` is used in `setup` to ensure a clean state for each test. - `Flippant.update_config/2` is used to set custom rules for testing. ``` -------------------------------- ### Migrate Between Adapters Source: https://context7.com/sorentwo/flippant/llms.txt Steps to migrate feature data from Redis to Postgres by dumping, reconfiguring the application, and reloading. ```elixir # 1. Dump from Redis Flippant.dump("migration.dump") # 2. Restart with Postgres adapter Application.stop(:flippant) Application.put_env(:flippant, :adapter, Flippant.Adapter.Postgres) Application.ensure_started(:flippant) Flippant.setup() # 3. Load into Postgres Flippant.clear() Flippant.load("migration.dump") #=> :ok ``` -------------------------------- ### Test Features with Memory Adapter Source: https://context7.com/sorentwo/flippant/llms.txt Configures the Memory adapter for isolated testing and demonstrates verifying feature access. ```elixir # config/test.exs config :flippant, adapter: Flippant.Adapter.Memory # test/features_test.exs defmodule FeaturesTest do use ExUnit.Case setup do # Clear features between tests Flippant.clear() # Setup test rules Flippant.update_config(:rules, MyApp.TestRules) on_exit(fn -> Flippant.update_config(:rules, Flippant.Rules.Default) end) end test "staff users can access admin features" do Flippant.enable("admin_panel", "staff") staff = %{id: 1, staff?: true} regular = %{id: 2, staff?: false} assert Flippant.enabled?("admin_panel", staff) refute Flippant.enabled?("admin_panel", regular) end test "beta features can be enabled for specific users" do Flippant.enable("new_ui", "beta_testers", [100, 101, 102]) beta_user = %{id: 101, staff?: false} other_user = %{id: 999, staff?: false} assert Flippant.enabled?("new_ui", beta_user) refute Flippant.enabled?("new_ui", other_user) end end ``` -------------------------------- ### Register Feature Groups at Startup Source: https://context7.com/sorentwo/flippant/llms.txt Registers custom evaluation functions for feature groups within a supervision tree. ```elixir # lib/my_app/feature_groups.ex defmodule MyApp.FeatureGroups do def start_link do # Register group evaluation functions Flippant.register("everybody", fn _actor, _values -> true end) Flippant.register("nobody", fn _actor, _values -> false end) Flippant.register("staff", fn %{staff?: true}, _values -> true _, _ -> false end) Flippant.register("beta_testers", fn %{id: id}, ids -> id in ids _, _ -> false end) Flippant.register("percentage", fn _actor, [] -> false %{id: id}, samples -> rem(id, 10) in samples _, _ -> false end) :ignore end end # lib/my_app/application.ex defmodule MyApp.Application do use Application def start(_type, _args) do children = [ {Flippant, []}, {MyApp.FeatureGroups, [], restart: :temporary} ] opts = [strategy: :one_for_one, name: MyApp.Supervisor] Supervisor.start_link(children, opts) end end ``` -------------------------------- ### Flippant.clear/0 Source: https://context7.com/sorentwo/flippant/llms.txt Removes all features from the system. ```APIDOC ## Flippant.clear/0 ### Description Removes all features from the system. Useful for testing or resetting state. ### Response - **atom** - Returns :ok on success. ``` -------------------------------- ### Add Features to System Source: https://context7.com/sorentwo/flippant/llms.txt Register new features in the system. Feature names are automatically normalized. ```elixir # Add features to the system Flippant.add("search") #=> :ok Flippant.add("dark_mode") #=> :ok # Feature names are normalized (lowercase, trimmed) Flippant.add(" SEARCH ") #=> :ok # Same as "search" # Verify features were added Flippant.features() #=> ["dark_mode", "search"] ``` -------------------------------- ### Flippant.features/1 Source: https://context7.com/sorentwo/flippant/llms.txt Lists all known features, or only features enabled for a specific group. ```APIDOC ## Flippant.features/1 ### Description Lists all known features, or only features enabled for a specific group. ### Parameters - **group** (string/atom) - Optional - The group name to filter features by. ### Response - **list** - A list of feature names. ``` -------------------------------- ### Define and Check Feature Access Source: https://context7.com/sorentwo/flippant/llms.txt Define feature rules for actors and verify access using the enabled? function. ```elixir staff_user = %{id: 1, staff?: true, subscription: "free"} beta_user = %{id: 1002, staff?: false, subscription: "free"} regular_user = %{id: 9999, staff?: false, subscription: "free"} premium_user = %{id: 5000, staff?: false, subscription: "premium"} # Setup feature rules Flippant.enable("advanced_search", "staff") Flippant.enable("advanced_search", "beta_testers", [1001, 1002, 1003]) Flippant.enable("advanced_search", "premium") # Check access Flippant.enabled?("advanced_search", staff_user) #=> true (staff member) Flippant.enabled?("advanced_search", beta_user) #=> true (ID 1002 is in beta_testers list) Flippant.enabled?("advanced_search", regular_user) #=> false (not staff, not in beta list, not premium) Flippant.enabled?("advanced_search", premium_user) #=> true (premium subscriber) # Non-existent feature always returns false Flippant.enabled?("nonexistent_feature", staff_user) #=> false ``` -------------------------------- ### Flippant.exists?/2 Source: https://context7.com/sorentwo/flippant/llms.txt Checks whether a feature exists in the system, optionally checking if it has rules for a specific group. ```APIDOC ## Flippant.exists?/2 ### Description Checks whether a feature exists in the system, optionally checking if it has rules for a specific group. ### Parameters - **feature** (string) - Required - The name of the feature to check. - **group** (string) - Optional - The specific group to check for the feature. ### Response - **boolean** - Returns true if the feature (or feature/group combination) exists, false otherwise. ``` -------------------------------- ### Clear All Features Source: https://context7.com/sorentwo/flippant/llms.txt Remove all features from the system, useful for testing or state resets. ```elixir Flippant.enable("search", "staff") Flippant.enable("delete", "premium") Flippant.enable("export", "beta_testers", [1, 2, 3]) Flippant.features() #=> ["delete", "export", "search"] # Clear all features Flippant.clear() #=> :ok Flippant.features() #=> [] Flippant.breakdown() #=> %{} ``` -------------------------------- ### Add Flippant Dependency Source: https://github.com/sorentwo/flippant/blob/main/README.md Add Flippant to your project's dependencies in mix.exs. ```elixir def deps do [{:flippant, "~> 2.0"}] end ``` -------------------------------- ### Define Custom Feature Rules Source: https://context7.com/sorentwo/flippant/llms.txt Implement the Flippant.Rules behaviour to define group evaluation logic and register the module in the configuration. ```elixir defmodule MyApp.FeatureRules do @behaviour Flippant.Rules # Staff members always have access def enabled?("staff", _enabled_for, %{staff?: true}), do: true def enabled?("staff", _enabled_for, _actor), do: false # Check if actor's ID is in the enabled list def enabled?("beta_testers", enabled_for, actor) do Enum.any?(enabled_for, &(actor.id == &1)) end # Percentage-based rollout (10% increments) def enabled?("adopters", enabled_for, %{id: id}) do rem(id, 10) in enabled_for end # Premium subscribers def enabled?("premium", _enabled_for, %{subscription: "premium"}), do: true def enabled?("premium", _enabled_for, _actor), do: false # Default: no access def enabled?(_group, _enabled_for, _actor), do: false end # Configure to use custom rules Flippant.update_config(:rules, MyApp.FeatureRules) ``` -------------------------------- ### List Features Source: https://context7.com/sorentwo/flippant/llms.txt Retrieve a list of all features or features enabled for a specific group. ```elixir Flippant.enable("search", "staff") Flippant.enable("search", "premium") Flippant.enable("delete", "staff") Flippant.enable("export", "premium") Flippant.add("invite") # List all features Flippant.features() #=> ["delete", "export", "invite", "search"] Flippant.features(:all) #=> ["delete", "export", "invite", "search"] # List features for specific group Flippant.features("staff") #=> ["delete", "search"] Flippant.features("premium") #=> ["export", "search"] Flippant.features("beta_testers") #=> [] ``` -------------------------------- ### Check Feature Existence Source: https://context7.com/sorentwo/flippant/llms.txt Verify if a feature exists globally or for a specific group. ```elixir Flippant.enable("search", "staff") Flippant.enable("search", "beta_testers", [1, 2, 3]) Flippant.add("delete") # Check if feature exists Flippant.exists?("search") #=> true Flippant.exists?("delete") #=> true Flippant.exists?("unknown_feature") #=> false # Check if feature exists for specific group Flippant.exists?("search", "staff") #=> true Flippant.exists?("search", "premium") #=> false (feature exists but not enabled for premium) Flippant.exists?("delete", "staff") #=> false (feature exists but has no rules) ``` -------------------------------- ### Flippant.breakdown/1 Source: https://context7.com/sorentwo/flippant/llms.txt Generates a complete mapping of features and their rules or a boolean map for a specific actor. ```APIDOC ## Flippant.breakdown/1 ### Description Generates a complete mapping of features and their rules. Without arguments, returns all features with group metadata. With an actor, returns a boolean map of enabled features. ### Parameters - **actor** (map) - Optional - The actor object to check feature status against. ### Response - **map** - A map containing feature rules or boolean status for an actor. ``` -------------------------------- ### Flippant.add/1 Source: https://context7.com/sorentwo/flippant/llms.txt Adds a new feature to the Flippant system. Feature names are normalized to lowercase and trimmed. ```APIDOC ## Flippant.add/1 Adds a new feature without any rules enabled. This registers the feature in the system but does not grant access to any groups. ```elixir # Add features to the system Flippant.add("search") #=> :ok Flippant.add("dark_mode") #=> :ok # Feature names are normalized (lowercase, trimmed) Flippant.add(" SEARCH ") #=> :ok # Same as "search" # Verify features were added Flippant.features() #=> ["dark_mode", "search"] ``` ``` -------------------------------- ### Defining Custom Rules Source: https://context7.com/sorentwo/flippant/llms.txt Create custom modules to define specific logic for evaluating feature access based on actor attributes and group configurations. ```APIDOC ## Defining Custom Rules Create a rules module that defines how groups evaluate actors for feature access. ```elixir defmodule MyApp.FeatureRules do @behaviour Flippant.Rules # Staff members always have access def enabled?("staff", _enabled_for, %{staff?: true}), do: true def enabled?("staff", _enabled_for, _actor), do: false # Check if actor's ID is in the enabled list def enabled?("beta_testers", enabled_for, actor) do Enum.any?(enabled_for, &(actor.id == &1)) end # Percentage-based rollout (10% increments) def enabled?("adopters", enabled_for, %{id: id}) do rem(id, 10) in enabled_for end # Premium subscribers def enabled?("premium", _enabled_for, %{subscription: "premium"}), do: true def enabled?("premium", _enabled_for, _actor), do: false # Default: no access def enabled?(_group, _enabled_for, _actor), do: false end # Configure to use custom rules Flippant.update_config(:rules, MyApp.FeatureRules) ``` ``` -------------------------------- ### Enable Features for Groups Source: https://github.com/sorentwo/flippant/blob/main/README.md Set rules to enable a feature for specific groups. Rules can optionally include a list of IDs for targeted enablement. ```elixir Flippant.enable("search", "staff") Flippant.enable("search", "testers", [1818, 1819]) ``` -------------------------------- ### Flippant.enable/3 Source: https://context7.com/sorentwo/flippant/llms.txt Enables a feature for a specific group. Optionally, values can be provided which are passed to the custom rule evaluation function. ```APIDOC ## Flippant.enable/3 Enables a feature for a specific group, optionally with values that are passed to the rule evaluation function. ```elixir # Enable feature for a group without values Flippant.enable("search", "staff") #=> :ok # Enable feature for specific user IDs Flippant.enable("search", "beta_testers", [1001, 1002, 1003]) #=> :ok # Enable for 30% of users (IDs where id % 10 is 0, 1, or 2) Flippant.enable("new_dashboard", "adopters", [0, 1, 2]) #=> :ok # Values are merged, not replaced Flippant.enable("search", "beta_testers", [1004, 1005]) #=> :ok # beta_testers now includes [1001, 1002, 1003, 1004, 1005] # Enable for multiple groups Flippant.enable("export", "staff") Flippant.enable("export", "premium") #=> :ok ``` ``` -------------------------------- ### Enable Features for Groups Source: https://context7.com/sorentwo/flippant/llms.txt Enable features for specific groups, optionally passing values for rule evaluation. Values are merged into existing group configurations. ```elixir # Enable feature for a group without values Flippant.enable("search", "staff") #=> :ok # Enable feature for specific user IDs Flippant.enable("search", "beta_testers", [1001, 1002, 1003]) #=> :ok # Enable for 30% of users (IDs where id % 10 is 0, 1, or 2) Flippant.enable("new_dashboard", "adopters", [0, 1, 2]) #=> :ok # Values are merged, not replaced Flippant.enable("search", "beta_testers", [1004, 1005]) #=> :ok # beta_testers now includes [1001, 1002, 1003, 1004, 1005] # Enable for multiple groups Flippant.enable("export", "staff") Flippant.enable("export", "premium") #=> :ok ``` -------------------------------- ### Generate Feature Breakdown Source: https://context7.com/sorentwo/flippant/llms.txt Retrieve a mapping of features and rules, or a boolean map for a specific actor. ```elixir Flippant.enable("search", "staff") Flippant.enable("search", "beta_testers", [1001, 1002]) Flippant.enable("delete", "staff") Flippant.enable("export", "premium") # Get complete breakdown of all features and rules Flippant.breakdown() #=> %{ #=> "search" => %{"staff" => [], "beta_testers" => [1001, 1002]}, #=> "delete" => %{"staff" => []}, #=> "export" => %{"premium" => []} #=> } # Get breakdown for specific actor (useful for SPAs/APIs) staff_user = %{id: 1, staff?: true, subscription: "free"} Flippant.breakdown(staff_user) #=> %{"search" => true, "delete" => true, "export" => false} beta_user = %{id: 1001, staff?: false, subscription: "free"} Flippant.breakdown(beta_user) #=> %{"search" => true, "delete" => false, "export" => false} # Serialize for API response actor = %{id: 1, staff?: true} features_json = actor |> Flippant.breakdown() |> Jason.encode!() #=> "{\"search\":true,\"delete\":true,\"export\":false}" ``` -------------------------------- ### Flippant.rename/2 Source: https://context7.com/sorentwo/flippant/llms.txt Renames an existing feature while preserving all its rules. ```APIDOC ## Flippant.rename/2 ### Description Renames an existing feature while preserving all its rules. If the new name already exists, it will be overwritten. ### Parameters - **old_name** (string) - Required - The current name of the feature. - **new_name** (string) - Required - The new name for the feature. ### Response - **atom** - Returns :ok on success. ``` -------------------------------- ### Flippant.remove/1 Source: https://context7.com/sorentwo/flippant/llms.txt Completely removes a feature and all its associated rules from the system. ```APIDOC ## Flippant.remove/1 ### Description Completely removes a feature and all its associated rules from the system. ### Parameters - **feature** (string) - Required - The name of the feature to remove. ### Response - **atom** - Returns :ok on success. ``` -------------------------------- ### Check Feature Enablement Source: https://github.com/sorentwo/flippant/blob/main/README.md Use the `enabled?` function to check if a feature is enabled for a given actor. The actor's attributes are passed to the registered group functions. ```elixir Flippant.enabled?("search", %User{id: 1817, staff?: false}) #=> true Flippant.enabled?("search", %User{id: 1818, staff?: false}) #=> false Flippant.enabled?("search", %User{id: 1820, staff?: true}) #=> true ``` -------------------------------- ### Flippant.enabled?/2 Source: https://context7.com/sorentwo/flippant/llms.txt Checks if a feature is enabled for a given actor. Returns true if the actor is associated with any group that has access to the feature. ```APIDOC ## Flippant.enabled?/2 Checks if a feature is enabled for a specific actor. Returns true if the actor belongs to any group that has access. ```elixir # Example usage with custom rules defined earlier # Actor is staff Flippant.enabled?("search", %{staff?: true}) #=> true # Actor is a beta tester with ID 1001 Flippant.enabled?("search", %{id: 1001}) #=> true # Actor is not a beta tester with ID 999 Flippant.enabled?("search", %{id: 999}) #=> false # Actor is a premium subscriber Flippant.enabled?("export", %{subscription: "premium"}) #=> true # Actor is not a premium subscriber Flippant.enabled?("export", %{subscription: "free"}) #=> false ``` ``` -------------------------------- ### Remove Features Source: https://context7.com/sorentwo/flippant/llms.txt Delete a feature and all associated rules from the system. ```elixir Flippant.enable("search", "staff") Flippant.enable("delete", "staff") Flippant.features() #=> ["delete", "search"] # Remove a feature Flippant.remove("search") #=> :ok Flippant.features() #=> ["delete"] Flippant.exists?("search") #=> false ``` -------------------------------- ### Rename Features Source: https://context7.com/sorentwo/flippant/llms.txt Rename an existing feature while preserving its rules. Names are automatically normalized. ```elixir Flippant.enable("search", "staff") Flippant.enable("search", "beta_testers", [1, 2, 3]) # Rename feature Flippant.rename("search", "advanced_search") #=> :ok Flippant.features() #=> ["advanced_search"] Flippant.breakdown() #=> %{"advanced_search" => %{"staff" => [], "beta_testers" => [1, 2, 3]}} # Names are normalized Flippant.rename(" ADVANCED_SEARCH ", " SUPER_SEARCH ") #=> :ok Flippant.features() #=> ["super_search"] ``` -------------------------------- ### Flippant.disable/3 Source: https://context7.com/sorentwo/flippant/llms.txt Disables a feature for a group or removes specific values from a group's rule set. ```APIDOC ## Flippant.disable/3 Disables a feature for a group entirely, or removes specific values from a group's rule. ```elixir # Disable feature for entire group Flippant.disable("search", "beta_testers") #=> :ok # Remove specific user IDs from a group (keep group enabled) Flippant.enable("search", "beta_testers", [1001, 1002, 1003, 1004]) Flippant.disable("search", "beta_testers", [1003, 1004]) #=> :ok # beta_testers now only includes [1001, 1002] # Verify the change Flippant.breakdown() #=> %{"search" => %{"beta_testers" => [1001, 1002]}} ``` ``` -------------------------------- ### Register Feature Groups Source: https://github.com/sorentwo/flippant/blob/main/README.md Define named groups for features using anonymous functions. These functions determine if an actor belongs to a group. ```elixir Flippant.register("staff", fn %User{staff?: staff?}, _ -> staff?) Flippant.register("testers", fn %User{id: id}, ids -> id in ids end) ``` -------------------------------- ### Disable Features for Groups Source: https://context7.com/sorentwo/flippant/llms.txt Disable a feature for an entire group or remove specific values from a group's rule configuration. ```elixir # Disable feature for entire group Flippant.disable("search", "beta_testers") #=> :ok # Remove specific user IDs from a group (keep group enabled) Flippant.enable("search", "beta_testers", [1001, 1002, 1003, 1004]) Flippant.disable("search", "beta_testers", [1003, 1004]) #=> :ok # beta_testers now only includes [1001, 1002] # Verify the change Flippant.breakdown() #=> %{"search" => %{"beta_testers" => [1001, 1002]}} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.