Coder Social home page Coder Social logo

flippant's Introduction

Flippant

Build Status Coverage Status Hex version Inline docs

Flippant is a library for feature toggling in Elixir applications

Installation

  1. Add flippant to your list of dependencies in mix.exs:
def deps do
  [{:flippant, "~> 2.0"}]
end
  1. Add an adapter such as redix for Redis or postgrex for Postgres:
def deps do
  [{:redix, "~> 1.0"}]
end
  1. Set an adapter within your config.exs:
config :flippant,
       adapter: Flippant.Adapter.Redis,
       redis_opts: [url: System.get_env("REDIS_URL"), name: :flippant],
       set_key: "flippant-features"

Usage

Complete documentation is available online, but here is a brief overview:

Features are comprised of groups, and rules. Your application defines named groups, and you set rules to specify which groups are enabled for a particular feature. When it comes time to check if a feature is enabled for a particular actor (i.e. user or account), all the groups for a feature are evaluated. If the actor belongs to any of the groups then the feature is enabled.

All interaction happens directly through the Flippant module.

Define some basic groups:

Flippant.register("staff", fn %User{staff?: staff?}, _ -> staff?)
Flippant.register("testers", fn %User{id: id}, ids -> id in ids end)

Set a few rules for the "search" feature:

Flippant.enable("search", "staff")
Flippant.enable("search", "testers", [1818, 1819])

Check if the current user has access to a feature:

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

License

MIT License, see LICENSE.txt for details.

flippant's People

Contributors

christiantovar avatar dependabot-preview[bot] avatar dependabot[bot] avatar krainboltgreene avatar sorentwo avatar tylerwitt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flippant's Issues

Any chance of a hex release?

I've been banging my head on the table trying to work out how to get the current rule state out of flippant so they can be displayed on a frontend, turns out I needed the unreleased breakdown/0 if you could release 0.3 that would be awesome, then we don't have to point directly to the git repo :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.