# Rollout Adapter

> A Rollout adapter for importing Rollout data into Flipper.

View the [docs on importing](/docs/adapters#swapping-adapters).

Requires:

  * [Rollout](https://github.com/fetlife/rollout) ~> 2.0
  * Flipper >= 0.12

## Installation

Add it to your application's Gemfile with:

    $ bundle add flipper-rollout

Or install it yourself with:

    $ gem install flipper-rollout

## Usage

```ruby
require 'redis'
require 'rollout'
require 'flipper'
require 'flipper/adapters/redis'
require 'flipper/adapters/rollout'

# setup redis, rollout and rollout flipper
redis = Redis.new
rollout = Rollout.new(redis)
rollout_adapter = Flipper::Adapters::Rollout.new(rollout)
rollout_flipper = Flipper.new(rollout_adapter)

# setup flipper default instance
Flipper.configure do |config|
  config.adapter { Flipper::Adapters::Redis.new(redis) }
end

# import rollout into redis flipper
Flipper.import(rollout_flipper)
```

That was easy.

### Groups
If you're using [Rollout groups](https://github.com/fetlife/rollout#user-content-groups) you'll need to register them as [Flipper groups](/docs/features/groups):

*Rollout*
```ruby
$rollout.define_group(:caretakers) do |user|
  user.caretaker?
end
```

*Flipper*
```ruby
Flipper.register(:caretakers) do |user|
  user.caretaker?
end
```

### flipper_id

Rollout expects users to respond to *id* (or method specified in [Rollout#initialize](https://github.com/fetlife/rollout/blob/main/lib/rollout.rb#L135) opts) and stores this value in Redis when a feature is activated for a user.  You'll want to make sure that your Flipper actor's [flipper_id](/docs/features/actors) matches this logic.
