diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-03-15 14:19:45 +0100 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-03-28 15:16:41 +0200 |
commit | c729d9dae7ad8c32cbe93b590baa24c8133364e5 (patch) | |
tree | 45bccc7eca5c789821a2435e7a0f3f1c75fc9e0e /app/services/note_summary.rb | |
parent | 1c3c7fb25d972fc19d5b4bb371cb21094d81e478 (diff) | |
download | gitlab-ce-c729d9dae7ad8c32cbe93b590baa24c8133364e5.tar.gz |
Create metadata when creating system notes
Diffstat (limited to 'app/services/note_summary.rb')
-rw-r--r-- | app/services/note_summary.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/services/note_summary.rb b/app/services/note_summary.rb new file mode 100644 index 00000000000..a6f6320d573 --- /dev/null +++ b/app/services/note_summary.rb @@ -0,0 +1,20 @@ +class NoteSummary + attr_reader :note + attr_reader :metadata + + def initialize(noteable, project, author, body, action: nil, commit_count: nil) + @note = { noteable: noteable, project: project, author: author, note: body } + @metadata = { action: action, commit_count: commit_count }.compact + + set_commit_params if note[:noteable].is_a?(Commit) + end + + def metadata? + metadata.present? + end + + def set_commit_params + note.merge!(noteable_type: 'Commit', commit_id: note[:noteable].id) + note[:noteable] = nil + end +end |