This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2023-03-30 05:44:00 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module UserSettings::DSL
|
|
|
|
module ClassMethods
|
|
|
|
def setting(key, options = {})
|
|
|
|
@definitions ||= {}
|
|
|
|
|
|
|
|
UserSettings::Setting.new(key, options).tap do |s|
|
|
|
|
@definitions[s.key] = s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-08-14 09:52:45 -07:00
|
|
|
def setting_inverse_alias(key, original_key)
|
|
|
|
@definitions[key] = @definitions[original_key].inverse_of(key)
|
|
|
|
end
|
|
|
|
|
2023-03-30 05:44:00 -07:00
|
|
|
def namespace(key, &block)
|
|
|
|
@definitions ||= {}
|
|
|
|
|
|
|
|
UserSettings::Namespace.new(key).configure(&block).tap do |n|
|
|
|
|
@definitions.merge!(n.definitions)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def keys
|
|
|
|
@definitions.keys
|
|
|
|
end
|
|
|
|
|
|
|
|
def definition_for(key)
|
|
|
|
@definitions[key.to_sym]
|
|
|
|
end
|
|
|
|
|
|
|
|
def definition_for?(key)
|
|
|
|
@definitions.key?(key.to_sym)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.included(base)
|
|
|
|
base.extend ClassMethods
|
|
|
|
end
|
|
|
|
end
|