mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 05:26:02 +08:00
DEV: Add auto _map extensions for list site settings with no type (#23331)
Followup to eea74e0e32f704f0756202c3f3ae801bcc8ac8bb. Site settings which are a list without a list_type should also have the _map extension added which returns an array based on split("|"). For example: ``` SiteSetting.post_menu_map => ["read", "like"] ```
This commit is contained in:
@ -529,9 +529,14 @@ module SiteSettingExtension
|
||||
|
||||
# Same logic as above for group_list settings, with the caveat that normal
|
||||
# list settings are not necessarily integers, so we just want to handle the splitting.
|
||||
if type_supervisor.get_type(name) == :list &&
|
||||
%w[simple compact].include?(type_supervisor.get_list_type(name))
|
||||
define_singleton_method("#{clean_name}_map") { self.public_send(clean_name).to_s.split("|") }
|
||||
if type_supervisor.get_type(name) == :list
|
||||
list_type = type_supervisor.get_list_type(name)
|
||||
|
||||
if %w[simple compact].include?(list_type) || list_type.nil?
|
||||
define_singleton_method("#{clean_name}_map") do
|
||||
self.public_send(clean_name).to_s.split("|")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
define_singleton_method "#{clean_name}?" do
|
||||
|
Reference in New Issue
Block a user