1
0

namespace.rb 404 B

123456789101112131415161718192021
  1. # frozen_string_literal: true
  2. class UserSettings::Namespace
  3. attr_reader :name, :definitions
  4. def initialize(name)
  5. @name = name.to_sym
  6. @definitions = {}
  7. end
  8. def configure(&block)
  9. instance_eval(&block)
  10. self
  11. end
  12. def setting(key, options = {})
  13. UserSettings::Setting.new(key, options.merge(namespace: name)).tap do |s|
  14. @definitions[s.key] = s
  15. end
  16. end
  17. end