2014-09-02 18:07:02 +05:30
|
|
|
class Notification
|
|
|
|
#
|
|
|
|
# Notification levels
|
|
|
|
#
|
|
|
|
N_DISABLED = 0
|
|
|
|
N_PARTICIPATING = 1
|
|
|
|
N_WATCH = 2
|
|
|
|
N_GLOBAL = 3
|
2015-04-26 12:48:37 +05:30
|
|
|
N_MENTION = 4
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
attr_accessor :target
|
|
|
|
|
|
|
|
class << self
|
|
|
|
def notification_levels
|
2015-04-26 12:48:37 +05:30
|
|
|
[N_DISABLED, N_PARTICIPATING, N_WATCH, N_MENTION]
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def options_with_labels
|
|
|
|
{
|
|
|
|
disabled: N_DISABLED,
|
|
|
|
participating: N_PARTICIPATING,
|
|
|
|
watch: N_WATCH,
|
2015-04-26 12:48:37 +05:30
|
|
|
mention: N_MENTION,
|
2014-09-02 18:07:02 +05:30
|
|
|
global: N_GLOBAL
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def project_notification_levels
|
2015-04-26 12:48:37 +05:30
|
|
|
[N_DISABLED, N_PARTICIPATING, N_WATCH, N_GLOBAL, N_MENTION]
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(target)
|
|
|
|
@target = target
|
|
|
|
end
|
|
|
|
|
|
|
|
def disabled?
|
|
|
|
target.notification_level == N_DISABLED
|
|
|
|
end
|
|
|
|
|
|
|
|
def participating?
|
|
|
|
target.notification_level == N_PARTICIPATING
|
|
|
|
end
|
|
|
|
|
|
|
|
def watch?
|
|
|
|
target.notification_level == N_WATCH
|
|
|
|
end
|
|
|
|
|
|
|
|
def global?
|
|
|
|
target.notification_level == N_GLOBAL
|
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
def mention?
|
|
|
|
target.notification_level == N_MENTION
|
|
|
|
end
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
def level
|
|
|
|
target.notification_level
|
|
|
|
end
|
|
|
|
end
|