diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-07-11 12:21:05 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-07-11 12:21:05 -0500 |
commit | ea40c08d5f313defade9a939e5d5d841aa3ba902 (patch) | |
tree | c5f93926b0d4de603b66a7766f4cd910d7c6e906 /app/models/sent_notification.rb | |
parent | 92772f85c1c68858b962b4934f3c5ee2e0849c14 (diff) | |
download | gitlab-ce-ea40c08d5f313defade9a939e5d5d841aa3ba902.tar.gz |
Allow SentNotification#position to be set as string or hash
Diffstat (limited to 'app/models/sent_notification.rb')
-rw-r--r-- | app/models/sent_notification.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb index 016172c6d7e..f4bcb49b34d 100644 --- a/app/models/sent_notification.rb +++ b/app/models/sent_notification.rb @@ -72,6 +72,19 @@ class SentNotification < ActiveRecord::Base end end + def position=(new_position) + if new_position.is_a?(String) + new_position = JSON.parse(new_position) rescue nil + end + + if new_position.is_a?(Hash) + new_position = new_position.with_indifferent_access + new_position = Gitlab::Diff::Position.new(new_position) + end + + super(new_position) + end + def to_param self.reply_key end |