diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-04-06 10:05:57 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-04-06 10:51:45 -0500 |
commit | cc656a11992483911cefe035d579096581cfde57 (patch) | |
tree | 5af4a41d9ae36b3900fdfa0b312b125995c8818c /app/models/concerns/noteable.rb | |
parent | 64c1735c22871d94e0bda8b9f5aece2a29739236 (diff) | |
download | gitlab-ce-cc656a11992483911cefe035d579096581cfde57.tar.gz |
Refactor resolvability checks based on type
Diffstat (limited to 'app/models/concerns/noteable.rb')
-rw-r--r-- | app/models/concerns/noteable.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/models/concerns/noteable.rb b/app/models/concerns/noteable.rb index 631df4757a4..772ff6a6d2f 100644 --- a/app/models/concerns/noteable.rb +++ b/app/models/concerns/noteable.rb @@ -1,4 +1,29 @@ module Noteable + # Names of all implementers of `Noteable` that support resolvable notes. + RESOLVABLE_TYPES = %w(MergeRequest).freeze + + def base_class_name + self.class.base_class.name + end + + # Convert this Noteable class name to a format usable by notifications. + # + # Examples: + # + # noteable.class # => MergeRequest + # noteable.human_class_name # => "merge request" + def human_class_name + @human_class_name ||= base_class_name.titleize.downcase + end + + def supports_resolvable_notes? + RESOLVABLE_TYPES.include?(base_class_name) + end + + def supports_discussions? + DiscussionNote::NOTEABLE_TYPES.include?(base_class_name) + end + def discussion_notes notes end |