mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 01:57:15 +08:00
DEV: introduce new API to look up dynamic site setting
This removes all uses of both `send` and `public_send` from consumers of SiteSetting and instead introduces a `get` helper for dynamic lookup This leads to much cleaner and safer code long term as we are always explicit to test that a site setting is really there before sending an arbitrary string to the class It also removes a couple of risky stubs from the auth provider test
This commit is contained in:
@ -81,7 +81,7 @@ class Plugin::Instance
|
||||
end
|
||||
|
||||
def enabled?
|
||||
@enabled_site_setting ? SiteSetting.send(@enabled_site_setting) : true
|
||||
@enabled_site_setting ? SiteSetting.get(@enabled_site_setting) : true
|
||||
end
|
||||
|
||||
delegate :name, to: :metadata
|
||||
@ -532,7 +532,7 @@ class Plugin::Instance
|
||||
rescue NotImplementedError
|
||||
provider.authenticator.define_singleton_method(:enabled?) do
|
||||
Discourse.deprecate("#{provider.authenticator.class.name} should define an `enabled?` function. Patching for now.")
|
||||
return SiteSetting.send(provider.enabled_setting) if provider.enabled_setting
|
||||
return SiteSetting.get(provider.enabled_setting) if provider.enabled_setting
|
||||
Discourse.deprecate("#{provider.authenticator.class.name} has not defined an enabled_setting. Defaulting to true.")
|
||||
true
|
||||
end
|
||||
|
Reference in New Issue
Block a user