mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-18 21:03:27 +00:00
a9b5598c97
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
38 lines
695 B
Ruby
38 lines
695 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 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
|