@@ -44,46 +44,23 @@ def self.exist?(name)
4444 SiteSetting . where ( name : name ) . any?
4545 end
4646
47- # Checks whether the setting is a global site setting
48- # @return [Boolean]
47+ # Is the setting global?
48+ # @return [Boolean] check result
4949 def global?
5050 community_id . nil?
5151 end
5252
53- # Is the setting array-valued?
54- # @return [Boolean] check result
55- def array?
56- value_type . downcase == 'array'
57- end
58-
59- # Is the setting boolean-valued?
60- # @return [Boolean] check result
61- def boolean?
62- value_type . downcase == 'boolean'
63- end
64-
65- # Is the setting floating point number-valued?
66- # @return [Boolean] check result
67- def float?
68- value_type . downcase == 'float'
69- end
70-
71- # Is the setting integer-valued?
72- # @return [Boolean] check result
73- def integer?
74- value_type . downcase == 'integer'
75- end
76-
77- # Is the setting string-valued (plain text)?
78- # @return [Boolean] check result
79- def string?
80- value_type . downcase == 'string'
53+ # Defines predicates for each value type
54+ [ :array , :boolean , :float , :integer , :string , :text ] . each do |method |
55+ define_method "#{ method } ?" do
56+ value_type . downcase . to_sym == method
57+ end
8158 end
8259
83- # Is the setting text -valued (HTML-aware text) ?
60+ # Is the setting numeric -valued?
8461 # @return [Boolean] check result
85- def text ?
86- value_type . downcase == 'text'
62+ def numeric ?
63+ float? || integer?
8764 end
8865
8966 def typed
0 commit comments