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
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request