README.md

    Yet another Settings Plugin for Rails

    Gem Version Gem YARD

    Coverage Quality Outdated Vulnerabilities

    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.

    class GeneralSettings < Groupped::Settings::Group
      self.group_name = 'general'
    
      attribute :identifier, :string, default: 'application'
      attribute :secret, :string
    
      validates :identifier, presence: true
      validates :secret, length: { minimum: 16 }
    end
    

    Using global settings:

    s = GeneralSettings.load
    s.identifier = '123123123'
    s.save!
    
    s = Groupped::Settings[:general, GeneralSettings]
    s.secret = '12345678987654321'
    s.save!
    

    Using settings fot some model:

    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:

    class User
      include Groupped::Settings::Settingsable
    end
    
    
    s = User.first.settings_group(:general, GeneralSettings)
    
    Описание

    Groupped::Settings is a plugin that manage groupped settings for Rails :)

    Конвейеры
    0 успешных
    0 с ошибкой