mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-30 03:59:03 +01:00
fc5ab2dc83
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
41 lines
822 B
Ruby
41 lines
822 B
Ruby
# 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
|
|
|
|
def setting_inverse_alias(key, original_key)
|
|
@definitions[key] = @definitions[original_key].inverse_of(key)
|
|
end
|
|
|
|
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
|