discourse/app/serializers/concerns/user_primary_group_mixin.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

45 lines
954 B
Ruby

# frozen_string_literal: true
module UserPrimaryGroupMixin
def self.included(klass)
klass.attributes :primary_group_name,
:primary_group_flair_url,
:primary_group_flair_bg_color,
:primary_group_flair_color
end
def primary_group_name
object&.primary_group&.name
end
def include_primary_group_name?
object&.primary_group.present?
end
def primary_group_flair_url
object&.primary_group&.flair_url
end
def include_primary_group_flair_url?
object&.primary_group&.flair_url.present?
end
def primary_group_flair_bg_color
object&.primary_group&.flair_bg_color
end
def include_primary_group_flair_bg_color?
object&.primary_group&.flair_bg_color.present?
end
def primary_group_flair_color
object&.primary_group&.flair_color
end
def include_primary_group_flair_color?
object&.primary_group&.flair_color.present?
end
end