Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arkency/feature_toggle
A simple feature Toggle for a Rails app.
https://github.com/arkency/feature_toggle
Last synced: 5 days ago
JSON representation
A simple feature Toggle for a Rails app.
- Host: GitHub
- URL: https://github.com/arkency/feature_toggle
- Owner: arkency
- Created: 2017-02-03T12:59:13.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-03T13:03:47.000Z (almost 8 years ago)
- Last Synced: 2024-04-24T18:52:49.207Z (7 months ago)
- Language: Ruby
- Homepage:
- Size: 6.84 KB
- Stars: 4
- Watchers: 13
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FeatureToggle
A simple feature Toggle for a Rails app.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'arkency-feature_toggle'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install arkency-feature_toggle
## Usage
### Defining toggles
```ruby
FT = FeatureToggle.new.tap do |ft|
ft.for(:new_user_profile) do |user_id:|
Admin.where(user_id: user_id).exists?
end
end
```### Enabling given feature via toggle
```ruby
class UserProfilesController < ApplicationController
def show
FT.with(:new_user_profile, user_id: current_user.id) do
return render :new_user_profile, locals: { user: NewUserProfilePresenter.new(current_user) }
endrender :show, locals: { user: UserProfilePresenter.new(current_user) }
end
end
```### Convenience alias
```ruby
require 'arkency/feature_toggle/alias'
```From now on you can use top-level `::FeatureToggle`.
### Read more
[A simple feature toggle for a Rails app] (http://blog.arkency.com/2015/11/simple-feature-toggle-for-rails-app/) on Arkency blog.
## About
Feature Toggle funded and maintained by Arkency. Check out our other [open-source projects](https://github.com/arkency).
You can also [hire us](http://arkency.com) or [read our blog](http://blog.arkency.com).