Organize callouts code under users
The following discussion from !68785 (merged) should be addressed:
-
@mayra-cabrera started a discussion: (+7 comments) I agree the name is not perfect, and I can't think of a better option.
But thinking about it a bit more, not sure if this one should be a concern, the point of a model concern is to make the code more re-usable by sharing it across different models, but this concern is very specific to
User
, we're using to reduce the logic of that model, at the moment I don't visualize any other model that could include this concern. I think the whole problem is that we're trying to centralize logic betweenGroup
s andProject
s, which could be done by having a base class, something along the lines of:class BaseCallout has_many :callouts, class_name: 'UserCallout' # .... def dismissed_callout_for_source?(feature_name:, ignore_dismissal_earlier_than: nil) callout = callouts_by_source_feature_name[source_feature_name] callout_dismissed?(callout, ignore_dismissal_earlier_than) end private def source_feature_name raise NotImplemented end end class ProjectCallout < BaseCallout private def source_feature_name ":project_#{project_id}_#{feature_name}" end end class GroupCallout < BaseCallout private def source_feature_name ":group_#{group_id}_#{feature_name}" end end
Thoughts?