Mongoid::FeatureFlags

Out of the box simple usage of feature flags with Mongoid classes.

Installation

Add this line to your application's Gemfile:

gem 'mongoid-feature-flags'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mongoid-feature-flags

Usage

If you would like to add features on persons, include Mongoid::FeatureFlags

class Person
  include Mongoid::Document

  has_many :possessions
  belongs_to :family

  include Mongoid::FeatureFlags
  inherits_features_from :family
  include_generated_features_from :other_features_method

  def other_features_method
    {:play_guitar_like_bo_diddley => true}
  end
end

Then, you can do the following:

p = Person.first
p.add_feature(:play_guitar_like_slash)

p.feature?(:play_guitar_like_slash) { *works* }
p.feature?(:play_guitar_like_bo_diddley) { *works* }

p.feature?(:play_guitar_like_nikki_sixx) { *does not work* }   

Security

Rails 3.2

You are responsible for using strong_parameters at the controller level.

< Rails 3.2

You are responsible for adding attr_accessible or attr_protected to your classes for security.

Contributing

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