discourse/app/serializers/auth_provider_serializer.rb
Sam Saffron 9be70a22cd 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
2019-05-07 11:00:30 +10:00

28 lines
770 B
Ruby

class AuthProviderSerializer < ApplicationSerializer
attributes :name, :custom_url, :pretty_name_override, :title_override, :message_override,
:frame_width, :frame_height, :full_screen_login, :can_connect, :can_revoke,
:icon
def title_override
return SiteSetting.get(object.title_setting) if object.title_setting
object.title
end
def pretty_name_override
return SiteSetting.get(object.pretty_name_setting) if object.pretty_name_setting
object.pretty_name
end
def full_screen_login
return SiteSetting.get(object.full_screen_login_setting) if object.full_screen_login_setting
return object.full_screen_login if object.full_screen_login
false
end
def message_override
object.message
end
end