Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rnd-soft/groupped_settings
[MIRROR] Groupped::Settings is a plugin that manage groupped settings for Rails :)
https://github.com/rnd-soft/groupped_settings
gem rails ruby ruby-on-rails
Last synced: about 7 hours ago
JSON representation
[MIRROR] Groupped::Settings is a plugin that manage groupped settings for Rails :)
- Host: GitHub
- URL: https://github.com/rnd-soft/groupped_settings
- Owner: RND-SOFT
- License: mit
- Created: 2019-11-06T13:39:33.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-14T12:03:37.000Z (11 months ago)
- Last Synced: 2024-03-14T17:33:49.430Z (8 months ago)
- Topics: gem, rails, ruby, ruby-on-rails
- Language: Ruby
- Homepage: https://br.rnds.pro/ruby/groupped_settings
- Size: 38.1 KB
- Stars: 4
- Watchers: 6
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# Yet another Settings Plugin for Rails
[![Gem Version](https://badge.fury.io/rb/groupped_settings.svg)](https://rubygems.org/gems/groupped_settings)
[![Gem](https://img.shields.io/gem/dt/groupped_settings.svg)](https://rubygems.org/gems/groupped_settings/versions)
[![YARD](https://badgen.net/badge/YARD/doc/blue)](http://www.rubydoc.info/gems/groupped_settings)[![Coverage](https://lysander.rnds.pro/api/v1/badges/gs_coverage.svg)](https://lysander.x.rnds.pro/api/v1/badges/gs_coverage.html)
[![Quality](https://lysander.rnds.pro/api/v1/badges/gs_quality.svg)](https://lysander.x.rnds.pro/api/v1/badges/gs_quality.html)
[![Outdated](https://lysander.rnds.pro/api/v1/badges/gs_outdated.svg)](https://lysander.x.rnds.pro/api/v1/badges/gs_outdated.html)
[![Vulnerabilities](https://lysander.rnds.pro/api/v1/badges/gs_vulnerable.svg)](https://lysander.x.rnds.pro/api/v1/badges/gs_vulnerable.html)Groupped::Settings is a plugin that manage groupped settings for Rails :) Settings stored in own database table as json(b) field. Splitted by groups and can have polymorphyc referece to other models.
## Setup
`rails g rake groupped_settings:install`
`rails g rake groupped:settings:migration`Now update your database with:
`rake db:migrate`
## Usage
Define settings group class.
```ruby
class GeneralSettings < Groupped::Settings::Group
self.group_name = 'general'attribute :identifier, :string, default: 'application'
attribute :secret, :stringvalidates :identifier, presence: true
validates :secret, length: { minimum: 16 }
end
```Using global settings:
```ruby
s = GeneralSettings.load
s.identifier = '123123123'
s.save!s = Groupped::Settings[:general, GeneralSettings]
s.secret = '12345678987654321'
s.save!
```Using settings fot some model:
```ruby
s = GeneralSettings.load(target: User.first)
s.identifier = '123123123'
s.save!s = Groupped::Settings[:general, User.first]
s.secret = '12345678987654321'
s.save!
```Include Settingsable concern:
```ruby
class User
include Groupped::Settings::Settingsable
ends = User.first.settings_group(:general, GeneralSettings)
```