gitlab-org--gitlab-foss/app/models/notification.rb

55 lines
894 B
Ruby
Raw Normal View History

2013-03-27 13:04:29 -04:00
class Notification
#
# Notification levels
#
N_DISABLED = 0
N_PARTICIPATING = 1
N_WATCH = 2
N_GLOBAL = 3
2013-03-27 13:04:29 -04:00
attr_accessor :target
2013-03-27 13:04:29 -04:00
class << self
def notification_levels
[N_DISABLED, N_PARTICIPATING, N_WATCH]
end
def options_with_labels
{
disabled: N_DISABLED,
participating: N_PARTICIPATING,
watch: N_WATCH,
global: N_GLOBAL
}
end
def project_notification_levels
[N_DISABLED, N_PARTICIPATING, N_WATCH, N_GLOBAL]
end
end
def initialize(target)
@target = target
2013-03-27 13:04:29 -04:00
end
def disabled?
target.notification_level == N_DISABLED
2013-03-27 13:04:29 -04:00
end
def participating?
target.notification_level == N_PARTICIPATING
2013-03-27 13:04:29 -04:00
end
def watch?
target.notification_level == N_WATCH
end
def global?
target.notification_level == N_GLOBAL
2013-03-27 13:04:29 -04:00
end
def level
target.notification_level
end
2013-03-27 13:04:29 -04:00
end