blob: 26238bbbe8148b6c32085b21d53ba689b9e9f27c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# 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
|