<commit_before>**Note: This gem is still under construction!**

# feature_setting

[![Code Climate](https://codeclimate.com/github/indrode/feature_setting/badges/gpa.svg)](https://codeclimate.com/github/indrode/feature_setting) [![Test Coverage](https://codeclimate.com/github/indrode/feature_setting/badges/coverage.svg)](https://codeclimate.com/github/indrode/feature_setting/coverage)

This gem introduces the concept of "features" and "settings" to your Rails app. It provides an easy way to define such features and settings with default values right in your code and will persist them in the database.

- a feature is a key that can either be enabled or disabled
- a setting is a key that has a value (of type String, Fixnum, Float, or Array)

In practice, features can be used to switch certain functionality in your code on or off. This can be used to roll out functionality without the need to deploy. Settings are very flexible in that they can hold any value. The possibilities are endless.

Both, features and settings are configured with default values that persist in the database and then can be updated if required.

```ruby
# using features:
if Feature.caching_enabled?
  # do this
else
  # do that
end

# using settings:
if Setting.error_threshold > 500
    # do this
end

if Setting.allowed_users.include?(current_user)
  # to that<commit_msg>Add gem version badge to README<commit_after># feature_setting

[![Gem Version](https://badge.fury.io/rb/feature_setting.svg)](http://badge.fury.io/rb/feature_setting) [![Code Climate](https://codeclimate.com/github/indrode/feature_setting/badges/gpa.svg)](https://codeclimate.com/github/indrode/feature_setting) [![Test Coverage](https://codeclimate.com/github/indrode/feature_setting/badges/coverage.svg)](https://codeclimate.com/github/indrode/feature_setting/coverage)

This gem introduces the concept of "features" and "settings" to your Rails app. It provides an easy way to define such features and settings with default values right in your code and will persist them in the database.

- a feature is a key that can either be enabled or disabled
- a setting is a key that has a value (of type String, Fixnum, Float, or Array)

In practice, features can be used to switch certain functionality in your code on or off. This can be used to roll out functionality without the need to deploy. Settings are very flexible in that they can hold any value. The possibilities are endless.

Both, features and settings are configured with default values that persist in the database and then can be updated if required.

```ruby
# using features:
if Feature.caching_enabled?
  # do this
else
  # do that
end

# using settings:
if Setting.error_threshold > 500
    # do this
end

if Setting.allowed_users.include?(current_user)
  # to that
{'fraction_non_alphanumeric': 0.08008580622095102, 'fraction_numerical': 0.0021451555237754737, 'mean_word_length': 4.7218813905930475, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 9, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2382713', 'n_tokens_mistral': 790, 'n_tokens_neox': 763, 'n_words': 332}