Skip to content

Commit

Permalink
Update readme to new dsl and add types
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Aug 2, 2012
1 parent 502e824 commit c0d59b6
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,45 @@ Feature flipper for any adapter.
## Usage

```ruby
require 'flipper'
require 'flipper/adapters/memory'

# pick an adapter
adapter = Flipper::Adapters::Memory.new
search = Flipper::Feature.new(:search, adapter)

if search.enabled?
puts 'Search away!'
else
puts 'No search for you!'
# get a handy dsl instance
flipper = Flipper.new(adapter)

# grab a feature
search = flipper[:search]

perform = lambda do
# check if that feature is enabled
if search.enabled?
puts 'Search away!'
else
puts 'No search for you!'
end
end

perform.call
puts 'Enabling Search...'
search.enable

if search.enabled?
puts 'Search away!'
else
puts 'No search for you!'
end
perform.call
```

Of course there are more [examples for you to peruse](https://github.com/jnunemaker/flipper/tree/master/examples).

## Types

Out of the box several types of enabling are supported:

* Boolean - All on or all off.
* Group - Turn on feature based on value of block. Super flexible way to turn on a feature for multiple things (users, people, accounts, etc.)
* Individual Actor - Turn on for individual thing. Think enable feature for someone to test or for a buddy.
* Percentage of Actors - Turn this on for a percentage of actors (think users or people). Consistently on or off for this user as long as percentage increases. Think slow rollout of a new feature to users.
* Percentage of Random - Turn this on for a random percentage of time

## Installation

Add this line to your application's Gemfile:
Expand Down

0 comments on commit c0d59b6

Please sign in to comment.