Use cattr_accessor instead duplicating code on NoteOnDiff concern
This commit is contained in:
parent
66c4ed6165
commit
16c9abf1ee
3 changed files with 10 additions and 10 deletions
|
@ -14,14 +14,14 @@ module Mentionable
|
||||||
attr = attr.to_s
|
attr = attr.to_s
|
||||||
mentionable_attrs << [attr, options]
|
mentionable_attrs << [attr, options]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Accessor for attributes marked mentionable.
|
|
||||||
def mentionable_attrs
|
|
||||||
@mentionable_attrs ||= []
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
included do
|
included do
|
||||||
|
# Accessor for attributes marked mentionable.
|
||||||
|
cattr_accessor :mentionable_attrs, instance_accessor: false do
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
if self < Participable
|
if self < Participable
|
||||||
participant -> (user, ext) { all_references(user, extractor: ext) }
|
participant -> (user, ext) { all_references(user, extractor: ext) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,9 +4,6 @@ module NoteOnDiff
|
||||||
NUMBER_OF_TRUNCATED_DIFF_LINES = 16
|
NUMBER_OF_TRUNCATED_DIFF_LINES = 16
|
||||||
|
|
||||||
included do
|
included do
|
||||||
attr_mentionable :note, pipeline: :note
|
|
||||||
participant :author
|
|
||||||
|
|
||||||
delegate :blob, :highlighted_diff_lines, to: :diff_file, allow_nil: true
|
delegate :blob, :highlighted_diff_lines, to: :diff_file, allow_nil: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,12 @@ module Participable
|
||||||
def participant(attr)
|
def participant(attr)
|
||||||
participant_attrs << attr
|
participant_attrs << attr
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def participant_attrs
|
included do
|
||||||
@participant_attrs ||= []
|
# Accessor for participant attributes.
|
||||||
|
cattr_accessor :participant_attrs, instance_accessor: false do
|
||||||
|
[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue