about summary refs log tree commit diff
path: root/app/models/user_settings/namespace.rb
blob: b8f7e092e805fa0927c38e8250c194815f64c07b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

class UserSettings::Namespace
  attr_reader :name, :definitions

  def initialize(name)
    @name        = name.to_sym
    @definitions = {}
  end

  def configure(&block)
    instance_eval(&block)
    self
  end

  def setting(key, options = {})
    UserSettings::Setting.new(key, options.merge(namespace: name)).tap do |s|
      @definitions[s.key] = s
    end
  end
end