corral

Use Corral to disable certain features in your application.


License
MIT
Install
gem install corral -v 0.1.3

Documentation

Corral

Code Climate Travic CI

Corral

Use Corral to disable certain features in your application.

Is it any good?

Yes

What was your inspiration?

I love Paddock (for which Corral should be a nearly drop-in replacement), but found its Rails environment specific approach to be too concrete for my needs. Specifically, I wanted to toggle my features on arbitrary--or at least callable--Ruby expressions.

Setup

Put this somewhere like: config/initializers/corral.rb

include Corral

# Pass an environment to use the `in` option...
Corral.corral(Rails.env) do
  disable :torpedoes, when: -> { true }
  disable :fun_and_games, in: [:staging, :production]
  disable :cupcakes, if: ->(person) { person == "Bryan" }
end

("when" and "if" mean the same thing. Use whichever makes you happy.)

If you don't mind polluting your global namespace and want to more easily refer to these methods, you can include Corral::Helpers

include Corral::Helpers

corral(Rails.env) do
  disable :caching, in: [:development, :test, :staging]
  enable :crying, when: ->(user) { user.birthday == Date.today }
end

Usage

# If you've included Corral::Helpers
fire! if enabled?(:torpedoes)
sulk if disabled?(:cupcakes, "Bryan") # And I don't even *like* sweets!

# If you've only included Corral
fire! if Corral.enabled?(:torpedoes)
sulk if Corral.disabled?(:cupcakes, "Bryan")

Installation

Add this line to your application's Gemfile:

gem 'corral'

And then execute:

$ bundle

Or install it yourself as:

$ gem install corral

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request